### Node.js Project Setup Source: https://context7.com/defaultuploader/documentation/llms.txt Commands to create a new Node.js project, install dependencies, and run the server. ```bash mkdir myuploaderserver && cd myuploaderserver && npm init -y npm i axios express multer form-data node index.js ``` -------------------------------- ### Start MinIO Services Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/s3-list/minio.mdx Navigate to the MinIO directory and start the Docker Compose services. This command initiates the MinIO server and its associated utilities. ```sh cd minio-for-local-development && docker-compose -f docker-compose.minio.yml up ``` -------------------------------- ### Start Express Server Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/examples/node-js.mdx Run the Node.js application to start the Express server. ```js node index.js ``` -------------------------------- ### Install Dependencies Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/examples/node-js.mdx Install necessary npm packages for building the Express server, handling requests, and making HTTP calls. ```bash npm i axios express multer form-data ``` -------------------------------- ### Backblaze Endpoint and Region Example Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/s3-list/backblaze.mdx Example values for Backblaze endpoint URL and region. Always verify with Backblaze documentation as these can change. ```plaintext // it's best to check with the provider's documentation // the endpoint is indicated on your bucket's card endpoint_url: (example) https://s3.us-east-005.backblazeb2.com region: Check from the endpoint_url, "us-east-005" is the region ``` -------------------------------- ### CDN Settings Example Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/prerequisites.mdx Configure your CDN to point to Default Uploader. Use API_KEY as a subdomain or specify the HOST in your personal account settings. ```text domain origin cdn.site.com api.defaultuploader.com ``` -------------------------------- ### Image Optimization Example Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/prerequisites.mdx Enable image optimization by appending the 'q' parameter to your CDN-served image URLs. Adjust the quality value as needed. ```text https://cdn.sitename.com/image.jpg?q=75 ``` -------------------------------- ### Upload Response Example Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/first-file.mdx This is an example of the JSON response you will receive after a successful file upload. It contains URLs for the uploaded file and its original source, along with metadata. ```js { "src": "https://api.defaultuploader.com/v1/upload/mvgfC8E5UkfrkWTHq9ydYc/sQeWeYhRczFmpPKrSihVy1.jpg", "originalSrc": "https://s3.ru-1.storage.selcloud.ru/files/image/jpg/sQeWeYhRczFmpPKrSihVy3.jpg", "originalName": "file_example_JPG_100kB.jpg", "s3PathOriginal": "image/jpg/sQeWeYhRczFmpPKrSihVy3.jpg", "s3Path": "image/jpg/sQeWeYhRczFmpPKrSihVy3.jpg", "options": {}, "size": 102117, "mimeType": "image", "format": "jpg" } ``` -------------------------------- ### Image Optimization Example Source: https://context7.com/defaultuploader/documentation/llms.txt Compares an original image tag with an automatically optimized version using default settings. ```html ``` -------------------------------- ### Video Transformation URL Example Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/video.mdx This is a base URL for initiating a video transformation, potentially with optimization parameters. ```url https://api.defaultuploader.com/v1/video/upload/token/sample.mp4?q_a ``` -------------------------------- ### Image URL Transformation Example Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/prerequisites.mdx Update your application's image and video URLs to use the configured CDN domain for enhanced performance and optimization. ```text https://sitename.com/image.jpg -> https://cdn.sitename.com/image.jpg ``` -------------------------------- ### URL-based Image Transformation Example Source: https://github.com/defaultuploader/documentation/blob/master/README.md Demonstrates how to transform an image by appending parameters to its URL. This is a simple way to modify image dimensions on the fly. ```text image.jpg?width=100 ``` -------------------------------- ### Example Presigned URL Structure Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/presigned-url.mdx This is an example of a presigned URL. The path is encrypted and modifications will fail the upload, making it safe to share. ```plaintext // The path is encrypted in the link. Any modification to the link will result in a failed upload. // Therefore, it is safe to share with third parties. Example of a presigned URL: https://api.defaultuploader.com/v1/upload/sign/huFtjXfdtfU8kzRB4roo2M \ /4261209739480817x-params7cdc34f921f1a8703c979dc0224b3a83x-token62bb1d \ 46ad31e402f4238a0ec4054a615bec5727dee08070bd9c2bbeb3f7c960dc0131eeefa9 \ 1b5a2db01f40e86da32c706262cf87b48727c885f776efa4a80b/dfdfdf.sddsfdsfs/ \ dfsfs.fdsf?expirationIn=3600 ``` -------------------------------- ### Enter Prefix in Bucket Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/scan.mdx To scan only a portion of the bucket, enter a prefix in the dashboard. This specifies the starting path for the scan. ```html /mysite.com/dogs ``` -------------------------------- ### CDN Configuration - Origin to S3 Source: https://context7.com/defaultuploader/documentation/llms.txt Maximum efficiency CDN setup where the CDN points directly to S3, serving pre-transformed files. On-the-fly optimization is not available. ```text User → CDN → S3 (pre-transformed files) ``` -------------------------------- ### Upload File Response Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/rest.mdx This is an example of the JSON response received after a successful file upload. ```json [ { "sourceName": "7uLbiXh7867H7dEPpsubV9.png", "src": "https://api.defaultuploader.com/v1/image/upload/azxwjk4PCkLTFbuUYiQZ1j/7uLbiXh7867H7dEPpsubV9.png", "originalSrc": "https://hb.vkcs.cloud/defaultuploader/image/png/7uLbiXh7867H7dEPpsubV9.png", "originalName": "dark_theme.png", "s3PathOriginal": "image/png/7uLbiXh7867H7dEPpsubV9.png", "s3Path": "image/png/7uLbiXh7867H7dEPpsubV9.png", "options": {}, "size": 1400308, "mimeType": "image", "format": "png" } ] ``` -------------------------------- ### Enable Adaptive Keyframe Placement Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/video.mdx Activate `kf_boost` for adaptive keyframe placement, prioritizing more frequent keyframes at the video start for better initial playback and seek performance. This parameter overrides `keyframe` if both are present. ```url ?kf_boost ``` -------------------------------- ### CDN Configuration - Origin to Default Uploader API Source: https://context7.com/defaultuploader/documentation/llms.txt Recommended CDN setup where the CDN origin points to the Default Uploader API, enabling full dynamic transformations. ```text CDN origin: api.defaultuploader.com User → CDN → Default Uploader → S3 ``` -------------------------------- ### Construct GET Request for Soft Migration Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/soft-migration.mdx Use this format to retrieve files when soft migration is enabled. Replace MIME_TYPE with image, video, or audio. The path after CLIENT_TOKEN should be the full path from the bucket root. ```sh https://api.defaultuploader.com/v1/MIME_TYPE/upload/CLIENT_TOKEN/mysite.com/cats/image/n.../file.jpg ``` -------------------------------- ### Upload Response Example Source: https://context7.com/defaultuploader/documentation/llms.txt This JSON structure represents the successful response after uploading a file. It includes source names, URLs for accessing the original and transformed files, and metadata. ```json [ { "sourceName": "7uLbiXh7867H7dEPpsubV9.png", "src": "https://api.defaultuploader.com/v1/image/upload/CLIENT_TOKEN/7uLbiXh7867H7dEPpsubV9.png", "originalSrc": "https://your-s3.storage.com/bucket/image/png/7uLbiXh7867H7dEPpsubV9.png", "originalName": "original_filename.png", "s3PathOriginal": "image/png/7uLbiXh7867H7dEPpsubV9.png", "s3Path": "image/png/7uLbiXh7867H7dEPpsubV9.png", "options": {}, "size": 1400308, "mimeType": "image", "format": "png" } ] ``` -------------------------------- ### Retrieve File (GET) Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/rest.mdx Use this endpoint to retrieve a file. Requires MIME_TYPE, CLIENT_TOKEN, and S3_PATH in the URL. ```sh https://api.defaultuploader.com/v1/MIME_TYPE/upload/CLIENT_TOKEN/S3_PATH ``` -------------------------------- ### Test File Upload with cURL Source: https://context7.com/defaultuploader/documentation/llms.txt Example cURL command to test the file upload endpoint of the Node.js server. ```bash curl --location 'http://localhost:3000/upload' \ --header 'Content-Type: image/svg+xml' \ --header 'Authorization: SECRET_CLIENT_TOKEN' \ --form 'image=@"/path/to/image.jpg"' ``` -------------------------------- ### Generate Presigned URL Endpoint Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/presigned-url.mdx Use this GET request to generate a presigned URL for file uploads. Specify the desired expiration time in seconds. ```sh # expirationIn - value in seconds /v1/sign/SECRET_CLIENT_TOKEN/CUSTOM_PATH_FOLDER?expirationIn=3600 ``` -------------------------------- ### CDN Middleware URL Transformation Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/cdn-middleware.mdx Illustrates how a standard image URL is transformed to use a CDN subdomain for optimized delivery. This example shows the 'before' and 'after' states of an image tag when the CDN middleware is applied. ```html // before // after // for example, if the default settings include [quality=75, format=auto] The image has been optimized and converted to the optimal format for the browser making the request. ``` -------------------------------- ### Upload with Custom Path Source: https://context7.com/defaultuploader/documentation/llms.txt Organize uploaded files into custom folders by appending the `?path=PATH` query parameter to the upload URL. This is useful for categorizing files, for example, by website domain or user identifier. ```bash curl --location 'https://api.defaultuploader.com/v1/upload?path=mysite.com/cats' \ --header 'Authorization: YOUR_SECRET_CLIENT_TOKEN' \ --form 'file=@"/path/to/cat.jpg"' ``` -------------------------------- ### Retrieve File for Soft Migration Source: https://context7.com/defaultuploader/documentation/llms.txt Construct a GET request with the full path from your bucket root to retrieve files, especially when integrating Default Uploader into an existing application. Transformations are supported regardless of the specified MIME type. ```http GET https://api.defaultuploader.com/v1/{MIME_TYPE}/upload/{CLIENT_TOKEN}/mysite.com/cats/image/file.jpg ``` -------------------------------- ### CURL Request Example Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/examples/node-js.mdx Send a file upload request to the server using cURL. Ensure the 'Authorization' header includes your secret token and the 'image' form field contains the file path. ```curl curl --location 'http://localhost:3000/upload' \ --header 'Content-Type: image/svg+xml' \ --header 'Authorization: SECRET_CLIENT_TOKEN' \ --form 'image=@"/C:/Users/user/Desktop/image.jpg"' ``` -------------------------------- ### Transform File via URL Query Parameters Source: https://context7.com/defaultuploader/documentation/llms.txt Modify the 'src' URL by appending query parameters to transform the file. For example, '?w=100' resizes the image to a width of 100 pixels. ```text https://api.defaultuploader.com/v1/image/upload/CLIENT_TOKEN/sample.jpg?w=100 ``` -------------------------------- ### GET /v1/:MIME_TYPE/upload/:CLIENT_TOKEN/:S3_PATH Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/rest.mdx Retrieves a file from the specified S3 path. Requires API version, MIME type, client token, and the S3 path. ```APIDOC ## GET /v1/:MIME_TYPE/upload/:CLIENT_TOKEN/:S3_PATH ### Description Retrieves a file from the specified S3 path. Requires API version, MIME type, client token, and the S3 path. ### Method GET ### Endpoint https://api.defaultuploader.com/v1/:MIME_TYPE/upload/:CLIENT_TOKEN/:S3_PATH ### Parameters #### Path Parameters - **MIME_TYPE** (string) - Required - The media type of the file (e.g., image, video, audio). - **CLIENT_TOKEN** (string) - Required - The client token obtained from the dashboard. - **S3_PATH** (string) - Required - The file path in your S3 storage. ### Response #### Success Response (200) - **cache-control** (string) - Cache control headers. - **etag** (string) - Entity tag for the file. - **accept-ranges** (string) - Indicates support for byte range requests. - **content-length** (integer) - Size of the file in bytes. - **content-range** (string) - Specifies the range of the content. - **content-type** (string) - The MIME type of the file. ``` -------------------------------- ### GET /v1/{MIME_TYPE}/upload/{CLIENT_TOKEN}/{S3_PATH} Source: https://context7.com/defaultuploader/documentation/llms.txt Retrieve a file and apply transformations via query parameters. Supported MIME types include image, video, and audio. ```APIDOC ## GET /v1/{MIME_TYPE}/upload/{CLIENT_TOKEN}/{S3_PATH} ### Description Retrieve a file from storage. Transformations can be applied by appending query parameters to the URL. The `MIME_TYPE` can be 'image', 'video', or 'audio'. ### Method GET ### Endpoint `/v1/{MIME_TYPE}/upload/{CLIENT_TOKEN}/{S3_PATH}` ### Parameters #### Path Parameters - **MIME_TYPE** (string) - Required - The media type of the file (e.g., 'image', 'video', 'audio'). - **CLIENT_TOKEN** (string) - Required - The client token obtained from the dashboard. - **S3_PATH** (string) - Required - The file path within your S3 storage. ### Query Parameters - **[transformation_parameters]** (string) - Optional - Query parameters to apply transformations (e.g., `w=100` for width). ### Response Headers - **cache-control** (string) - `public, max-age=604800` - **etag** (string) - File path. - **accept-ranges** (string) - `bytes` - **content-length** (string) - File size in bytes. - **content-type** (string) - MIME type of the file. ### Response Example (Response body depends on the file content and transformations applied. Headers are provided in the description.) Example of transforming an image: `https://api.defaultuploader.com/v1/image/upload/CLIENT_TOKEN/sample.jpg?w=100` ``` -------------------------------- ### Create Node.js App Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/examples/node-js.mdx Use npm to create a new Node.js project directory and initialize a package.json file. ```bash mkdir myuploaderserver && cd myuploaderserver && npm init -y ``` -------------------------------- ### docker-compose.minio.yml Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/s3-list/minio.mdx This script sets up MinIO and a utility for creating user credentials and a bucket. It requires the wait-for-it.sh script. ```sh version: '3.8' services: minio: image: minio/minio:latest container_name: minio environment: - MINIO_ROOT_USER=admin - MINIO_ROOT_PASSWORD=admin123 ports: - "9000:9000" - "9001:9001" volumes: - minio_data:/data command: server /data --console-address ':9001' minio_mc: image: minio/mc:latest container_name: minio_mc depends_on: - minio volumes: - ./wait-for-it.sh:/wait-for-it.sh entrypoint: > sh -c " chmod +x /wait-for-it.sh && /wait-for-it.sh minio:9000 --timeout=30 --strict && mc alias set myminio http://minio:9000 admin admin123 && if mc admin user info myminio my_access_key >/dev/null 2>&1; then echo 'User my_access_key already exists, skipping user creation'; else mc admin user add myminio my_access_key super_secret_key; fi && if mc ls myminio/mybucket >/dev/null 2>&1; then echo 'Bucket mybucket already exists, skipping bucket creation'; else mc mb myminio/mybucket; fi && if mc admin policy info myminio readwrite --user=my_access_key >/dev/null 2>&1; then echo 'Policy readwrite already attached to user my_access_key, skipping policy attachment'; else mc admin policy attach myminio readwrite --user=my_access_key; fi && echo ' The first two keys are needed to log into the MinIO WebUI management console, the second two keys are Access Key ID and Secret Access Key in your personal account admin.defaultuploader.com' && echo 'Username Minio UI: admin' && echo 'Password Minio UI: admin123' && echo 'Access Key: my_access_key' && echo 'Secret Access Key: super_secret_key' " volumes: minio_data: ``` -------------------------------- ### Image Transformations Source: https://context7.com/defaultuploader/documentation/llms.txt Apply various transformations to images via query parameters on GET requests. Transformed images are cached for subsequent requests. ```APIDOC ## Image Transformations Apply transformations via query parameters on GET requests. ``` https://api.defaultuploader.com/v1/image/upload/{CLIENT_TOKEN}/sample.jpg?w=100&q=75 ``` Transformed files are created on first request and cached for subsequent requests. ### Parameters #### width (alias: w) Resize width while maintaining aspect ratio. - Range: 0–5000 ``` ?w=100 ?w=200 ?w=300 ``` #### height (alias: h) Resize height while maintaining aspect ratio. - Range: 0–5000 ``` ?h=100 ?h=200 ``` #### format (alias: f) Convert to another image format. - Supported: JPEG, PNG, WebP, AVIF, TIFF, GIF, SVG, HEIC - `auto` — automatic browser format detection (coming soon) ``` ?f=webp ?f=avif ``` #### quality (alias: q) Adjust image quality. - Range: 0–100, default: 75 ``` ?q=100 ?q=50 ``` #### dpr Device pixel ratio for high-resolution screens. - Values: 1, 2 (default: 1) - Doubles the image dimensions when set to 2. ``` ?w=100&dpr=2 ``` #### animated (alias: a) Disable animation for GIF or WebP. ``` ?animated=0 ``` #### fit How the image is resized/cropped to fit target dimensions. - Values: `cover`, `contain`, `fill`, `inside`, `outside` ``` ?h=200&w=500&fit=cover ?h=200&w=500&fit=contain ``` #### func Smart crop using AI. - Values: `face`, `auto` - `face` — finds and centers on a face in the image. - `auto` — finds the "interesting" part of the image. ``` ?h=500&w=500&func=face ``` #### zoom (alias: z) Margin adjustment for smart cropping. - Range: 1–10, step: 0.1 ``` ?h=600&w=600&func=face&zoom=2 ``` #### blur Apply gaussian blur. - Range: 0.3–1000 ``` ?blur=10 ``` #### negate Create a negative of the image. ``` ?negate ``` ``` -------------------------------- ### Image Resize and Crop Fit Options Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Specify how the image should be resized or cropped using the `fit` parameter. Options include cover, contain, fill, inside, and outside. ```http h=200&w=500&fit=contain ``` ```http h=200&w=500&fit=cover ``` ```http h=200&w=500&fit=fill ``` ```http h=200&w=500&fit=inside ``` ```http h=200&w=500&fit=outside ``` -------------------------------- ### Predefined File Set Transformations Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/predefined-transformations.mdx Use this rule to create a set of images for different screen sizes and image formats. Each string in the array represents a transformation parameter. ```html ['w=360', 'w=768', 'w=1024'] ``` ```html ['w=360&f=avif', 'w=768&f=avif', 'w=1024&f=avif'] ``` -------------------------------- ### Expose MinIO Port with ngrok Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/s3-list/minio.mdx Use ngrok to expose the MinIO API port (9000) to the internet. This is necessary for external services to connect to your local MinIO instance. ```sh ngrok http 9000 ``` -------------------------------- ### Fetch Image by URL Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/fetch.mdx Download an image from a remote URL and apply transformations like resizing. Ensure you have your CLIENT_TOKEN. ```HTTP https://api.defaultuploader.com/v1/image/fetch/{CLIENT_TOKEN}/https://hot-dogs.com/holy-pick.jpg?w=100 ``` -------------------------------- ### Soft Migration Upload Retrieval Source: https://context7.com/defaultuploader/documentation/llms.txt Retrieve files uploaded by another system by constructing a GET request with the full path from your bucket root. This is useful for integrating with existing applications. ```APIDOC To retrieve a file, construct a GET request with the full path from your bucket root: ``` GET https://api.defaultuploader.com/v1/{MIME_TYPE}/upload/{CLIENT_TOKEN}/mysite.com/cats/image/file.jpg ``` `MIME_TYPE` can be any of: `image`, `video`, `audio`. Transformations work regardless of the specified value. ``` -------------------------------- ### Smart Cropping with AI Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Use the `func` parameter for smart cropping. Options include `face` to center faces or `auto` for AI-driven interesting area detection. ```http h=500&w=500&func=face ``` ```http h=500&w=500 ``` -------------------------------- ### Optimize Video Size with q_auto Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/video.mdx Use the `q_a` parameter to automatically optimize video settings for reduced file size while maintaining quality. This is an alias for `q_auto`. ```url ?q_a ``` -------------------------------- ### Generate Video Thumbnail Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/video.mdx Create a thumbnail image from the video using the `thumbnail` parameter. By default, a frame from the first 100ms is used. ```url ?thumbnail ``` -------------------------------- ### Generate Image Optimization Link Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/s3-list/minio.mdx Construct a URL to retrieve and optimize an uploaded image. Replace CLIENT_TOKEN with your actual token and S3_FILE_PATH with the path to the image. ```http https://api.defaultuploader.com/v1/image/upload/CLIENT_TOKEN/S3_FILE_PATH ``` -------------------------------- ### Resize Video by Width Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/video.mdx Set the desired width for the video using the `w` parameter (alias for `width`). The aspect ratio will be maintained. Valid range is 0 to 5000. ```url ?w=300 ``` -------------------------------- ### Add Width Parameter for Optimization Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/s3-list/minio.mdx Append the '?w=100' parameter to the image URL to specify a width of 100 pixels for optimization. ```http https://api.defaultuploader.com/v1/image/upload/66c78a393438de9506dd5e09/cat.jpg?w=100 ``` -------------------------------- ### Set Image Quality Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Use the `q` parameter to adjust the image quality. The range is from 0 to 100, with a default value of 75. ```http q=100 ``` ```http q=1 ``` -------------------------------- ### Upload with Custom Path Source: https://context7.com/defaultuploader/documentation/llms.txt Upload files and organize them into custom folders using the `path` query parameter. This allows for structured storage within your bucket. ```APIDOC ## Upload with Custom Path Add `?path=PATH` query parameter to organize files into custom folders. ```bash curl --location 'https://api.defaultuploader.com/v1/upload?path=mysite.com/cats' \ --header 'Authorization: YOUR_SECRET_CLIENT_TOKEN' \ --form 'file=@"/path/to/cat.jpg"' ``` Resulting bucket structure: ``` bucket/ mysite.com/ cats/ image/ jpg/ file.jpg ``` You can organize files by user identifiers (e.g., `?path=user@email.com`) to track resource usage per user. ``` -------------------------------- ### Fetching Images by URL Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/fetch.mdx This method allows you to download an image from a specified URL and apply necessary transformations (such as resizing, optimization, and other parameters). ```APIDOC ## GET /v1/image/fetch/{remote-file-url} ### Description Downloads an image from a specified URL and applies transformations. ### Method GET ### Endpoint `/v1/image/fetch/{remote-file-url}` ### Parameters #### Path Parameters - **remote-file-url** (string) - Required - The URL of the remote file to fetch. #### Query Parameters - **w** (integer) - Optional - The desired width of the image in pixels. ### Request Example `https://api.defaultuploader.com/v1/image/fetch/{CLIENT_TOKEN}/https://hot-dogs.com/holy-pick.jpg?w=100` ### Limitations Rate-limit: 50 requests per 5 seconds (can be increased upon request). ``` -------------------------------- ### Upload a File Source: https://context7.com/defaultuploader/documentation/llms.txt Use this cURL command to upload a file to the Default Uploader service. Ensure you replace 'YOUR_SECRET_CLIENT_TOKEN' with your actual token and '/path/to/file.jpg' with the correct file path. ```bash curl --location 'https://api.defaultuploader.com/v1/upload' \ --header 'Authorization: YOUR_SECRET_CLIENT_TOKEN' \ --form 'file=@"/path/to/file.jpg"' ``` -------------------------------- ### CDN Integration Source: https://context7.com/defaultuploader/documentation/llms.txt Guidance on integrating Default Uploader with a Content Delivery Network (CDN) for optimal performance and caching. ```APIDOC ## CDN Integration Default Uploader does not have its own CDN. For production, route traffic through a CDN. ### CDN Configuration Notes - Ensure query parameters are NOT ignored in CDN settings. - The service returns `cache-control: public, max-age=2592000` (30 days) for successful responses. ### Option 1: CDN → Default Uploader API (Recommended) Point your CDN origin to `https://api.defaultuploader.com`. This enables full dynamic transformation and optimization. ``` CDN origin: api.defaultuploader.com User → CDN → Default Uploader → S3 ``` ### Option 2: CDN → S3 (Maximum Efficiency) Point your CDN to S3 and use asynchronous transformations on upload. All subsequent requests are served by CDN without using Default Uploader resources. > Note: On-the-fly optimization does not work in this scenario. ``` User → CDN → S3 (pre-transformed files) ``` ``` -------------------------------- ### Image Saturation Parameter Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Sets the image saturation. The minimum value is 0.1. ```html Example image with parameters ``` ```html Example image with parameters ``` -------------------------------- ### Upload File (POST) Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/rest.mdx Use this endpoint to upload files using multipart/form-data. Requires an 'Authorization' header with your secret client token. ```sh curl --location 'https://api.defaultuploader.com/v1/upload' \ --header 'Authorization: YOUR_SECRET_CLIENT_TOKEN' \ --form 'file=@"/C:/path_to_file/file_example_JPG_100kB.jpg"' ``` -------------------------------- ### Predefined Image Set for Different Sizes and Formats Source: https://context7.com/defaultuploader/documentation/llms.txt Defines a set of transformations for creating images optimized for different screen sizes and formats like AVIF. ```array ['w=360&f=avif', 'w=768&f=avif', 'w=1024&f=avif'] ``` -------------------------------- ### Image Lightness Parameter Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Sets the image lightness. The minimum value is 0.1. ```html Example image with parameters ``` -------------------------------- ### Default File Transformation Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/predefined-transformations.mdx This rule enables file transformation with specified settings without requiring any additional parameters. It applies a default quality and width. ```html ['f=auto&q=75&w=768'] ``` -------------------------------- ### Upload File with Presigned URL (PUT) Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/rest.mdx Use this endpoint to upload files using a presigned URL. The URL includes parameters for expiration and path. ```sh https://api.defaultuploader.com/v1/upload/sign/7uLbiXh7867H7dEPpsubV9/5447114698657692x-params12d848eaca5282asdasda44766906ebx-token1427afc2d42ab2a200555c5d6b47a48b29cbffaac19cf572314ddafasddfd627ac0cdfabd6a134ggjhoda42728180a845e719ca0e0ce797ac/my-custom-folder.com?expirationIn=3600 ``` -------------------------------- ### Image Brightness Parameter Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Sets the image brightness. The minimum value is 0.1. ```html Example image with parameters ``` ```html Example image with parameters ``` -------------------------------- ### Resize Video by Height Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/video.mdx Set the desired height for the video using the `h` parameter (alias for `height`). The aspect ratio will be maintained. Valid range is 0 to 5000. ```url ?h=300 ``` -------------------------------- ### Convert to Greyscale Source: https://context7.com/defaultuploader/documentation/llms.txt Converts an image to black and white. ```url ?greyscale ``` -------------------------------- ### Image Hue Parameter Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Sets the image hue. The minimum value is 1. ```html Example image with parameters ``` -------------------------------- ### Selectel Object Storage Endpoint and Region Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/start/s3-list/selectel.mdx Essential configuration details for connecting to Selectel Object Storage. Always verify with the provider's official documentation for the most up-to-date information. ```plaintext endpoint_url: https://s3.ru-1.storage.selcloud.ru region: ru-1 ``` -------------------------------- ### Apply Image Transformations via Query Parameters Source: https://context7.com/defaultuploader/documentation/llms.txt Apply various image transformations by appending query parameters to the image URL. Transformed images are generated on the first request and cached for subsequent access. ```http https://api.defaultuploader.com/v1/image/upload/{CLIENT_TOKEN}/sample.jpg?w=100&q=75 ``` ```http ?w=100 ``` ```http ?w=200 ``` ```http ?w=300 ``` ```http ?h=100 ``` ```http ?h=200 ``` ```http ?f=webp ``` ```http ?f=avif ``` ```http ?q=100 ``` ```http ?q=50 ``` ```http ?w=100&dpr=2 ``` ```http ?animated=0 ``` ```http ?h=200&w=500&fit=cover ``` ```http ?h=200&w=500&fit=contain ``` ```http ?h=500&w=500&func=face ``` ```http ?h=600&w=600&func=face&zoom=2 ``` ```http ?blur=10 ``` ```http ?negate ``` -------------------------------- ### Predefined Image Set for Different Sizes Source: https://context7.com/defaultuploader/documentation/llms.txt Defines a set of transformations for creating images optimized for different screen sizes. ```array ['w=360', 'w=768', 'w=1024'] ``` -------------------------------- ### Upload with Presigned URL Source: https://context7.com/defaultuploader/documentation/llms.txt Use the `PUT` method to upload a file directly to a presigned URL. This is part of the integration flow for client-side uploads. ```APIDOC ### Upload with Presigned URL Use the `PUT` method to send a file to the presigned URL. ``` -------------------------------- ### Upload with Asynchronous Transformations Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/async-transform.mdx Use this cURL command to upload a file and specify multiple transformations to be applied asynchronously. The 'transforms' parameter accepts a JSON string array of transformation options. ```sh curl --location 'https://api.defaultuploader.com/v1/upload' \ --header 'Authorization: YOUR_SECRET_CLIENT_TOKEN' \ --form 'file=@"/C:/Users/UserName/Pictures/Saved Pictures/cat.jpg"' \ --form 'transforms="[\"w=100&h=100\",\"w=200&h=200\"]"' ``` -------------------------------- ### Express Server Implementation Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/examples/node-js.mdx This is the main server code for handling file uploads. It uses Express to create a route for uploads and Multer to process the incoming files before uploading them. ```js import express from 'express'; import multer from 'multer'; import axios from 'axios'; import FormData from 'form-data'; const app = express(); const port = 3000; const storage = multer.memoryStorage(); const upload = multer({ storage: storage }); const DEFAULT_UPLOADER_API_URL = 'http://localhost:8080/upload'; // Replace with your actual Default Uploader API URL const SECRET_CLIENT_TOKEN = 'YOUR_SECRET_CLIENT_TOKEN'; // Replace with your actual secret token app.post('/upload', upload.single('file'), async (req, res) => { if (!req.file) { return res.status(400).json({ message: 'No file uploaded' }); } try { const form = new FormData(); form.append('file', req.file.buffer, req.file.originalname); const response = await axios.post(DEFAULT_UPLOADER_API_URL, form, { headers: { ...form.getHeaders(), 'Authorization': SECRET_CLIENT_TOKEN, }, }); res.status(200).json(response.data); } catch (error) { console.error('Error uploading file:', error.response ? error.response.data : error.message); res.status(500).json({ message: 'Failed to upload file', error: error.message }); } }); app.listen(port, () => { console.log(`Server listening at http://localhost:${port}`); }); ``` -------------------------------- ### Fetch and Save Image to S3 Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/fetch.mdx Fetch an image from a remote URL and explicitly save it to S3 storage using the /fetch/keep endpoint. Requires CLIENT_TOKEN. ```HTTP GET https://api.defaultuploader.com/v1/image/fetch/keep/{CLIENT_TOKEN}/https://hot-dogs.com/holy-pick.jpg?w=100 ``` -------------------------------- ### Generate Presigned URL Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/presigned-url.mdx Request a presigned URL to upload a file directly to your storage bucket. The URL includes an expiration time and a custom path for organizing uploads. ```APIDOC ## Generate Presigned URL ### Description Generates a temporary, secure URL that allows a client to upload a file directly to a storage bucket without requiring authentication. The URL can be configured with an expiration time and a custom path. ### Method GET ### Endpoint `/v1/sign/SECRET_CLIENT_TOKEN/CUSTOM_PATH_FOLDER?expirationIn=SECONDS` ### Parameters #### Query Parameters - **expirationIn** (integer) - Optional - The duration in seconds for which the presigned URL will be valid. Defaults to a reasonable value if not provided. ### Request Example ```sh /v1/sign/SECRET_CLIENT_TOKEN/CUSTOM_PATH_FOLDER?expirationIn=3600 ``` ### Response #### Success Response (200) - **url** (string) - The generated presigned URL. #### Response Example ```json { "url": "https://api.defaultuploader.com/v1/upload/sign/huFtjXfdtfU8kzRB4roo2M/4261209739480817x-params7cdc34f921f1a8703c979dc0224b3a83x-token62bb1d46ad31e402f4238a0ec4054a615bec5727dee08070bd9c2bbeb3f7c960dc0131eeefa91b5a2db01f40e86da32c706262cf87b48727c885f776efa4a80b/dfdfdf.sddsfdsfs/dsfs.fdsf?expirationIn=3600" } ``` ### Notes - The generated URL is intended for use with the **PUT** HTTP method to upload the file. - Modifying the generated URL will result in a failed upload, making it safe to share. - Maximum URL length is 300 characters. - Maximum expiration duration is 604800 seconds (1 week). - Rate limit for generating links is 1000 per hour. ``` -------------------------------- ### Image Scanning (NSFW Detection) Source: https://context7.com/defaultuploader/documentation/llms.txt Information on how to scan images for NSFW content using bucket scans or upload webhooks. ```APIDOC ## Image Scanning (NSFW Detection) ### Bucket Scan Click the "Scan" button in the dashboard. A text file with addresses of detected NSFW content is generated. Enter a prefix to scan only a specific folder. ``` /mysite.com/dogs ``` ### Upload Webhook Every uploaded file is scanned for NSFW content. Configure a webhook URL in the dashboard to receive POST notifications with details about detected content. ``` -------------------------------- ### Set Image Width Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Use the `w` parameter to set the desired width for the image. The aspect ratio is preserved. Valid range is 0 to 5000. ```http w=100 ``` ```http w=200 ``` ```http w=300 ``` -------------------------------- ### Create Vertical Video Format Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/video.mdx Use the `vt` parameter (alias for `vertical`) to crop the video into a 9x16 aspect ratio, suitable for mobile viewing. ```url ?vt ``` -------------------------------- ### Specify Thumbnail Time Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/video.mdx Use the `duration` parameter in conjunction with `thumbnail` to specify the exact moment (in milliseconds) from which to capture the thumbnail frame. `1` equals 100ms. ```url ?thumbnail&duration=311 ``` -------------------------------- ### Upload File using Presigned URL Source: https://context7.com/defaultuploader/documentation/llms.txt Upload a file directly to the generated presigned URL using the HTTP `PUT` method. This method bypasses the need for direct API authentication. ```http PUT /path/to/presigned/url ``` -------------------------------- ### Set Keyframe Interval Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/video.mdx Control the keyframe interval (GOP size) using the `keyframe` parameter, with values ranging from 1 to 120. Lower values improve seek accuracy but increase file size. ```url ?keyframe=30 ``` -------------------------------- ### Enable High Resolution Display Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Use the `dpr` parameter to support high-resolution screens by doubling the image size. Accepts values 1 or 2. ```http w=100&dpr=1 ``` ```http w=100&dpr=2 ``` -------------------------------- ### Video Transformations Source: https://context7.com/defaultuploader/documentation/llms.txt Parameters for transforming videos, including quality optimization, resizing, format conversion, and thumbnail extraction. ```APIDOC ## Video Transformations Video transformation is resource-intensive. Use asynchronous transformations for video processing when possible. If a video has not yet been transformed, the API returns HTTP status `423` (file not ready). ``` https://api.defaultuploader.com/v1/video/upload/{CLIENT_TOKEN}/sample.mp4?q_a ``` ### Parameters #### q_auto (alias: q_a) Automatic quality optimization — preserves visual quality while significantly reducing file size. ``` ?q_a ``` Typical result: 50 MB original → 7 MB optimized. #### width (alias: w) Resize width while maintaining aspect ratio. - Range: 0–5000 ``` ?w=300 ``` #### height (alias: h) Resize height while maintaining aspect ratio. - Range: 0–5000 ``` ?h=300 ``` #### format (alias: f) Convert video format. - Supported: MP4, MOV, WEBM, AVI - Default: MP4 ``` ?f=webm ``` #### vertical (alias: vt) Create a 9:16 vertical video by cropping the center. Ideal for social media. ``` ?vt ``` Typical result with `q_a`: 50 MB original → 2.94 MB optimized vertical video. #### thumbnail Extract a thumbnail image from the video. ``` ?thumbnail ``` By default, uses a frame from the first 100ms. #### duration Specify the moment for thumbnail extraction (works only with `thumbnail`). - 1 = 100ms ``` ?thumbnail&duration=311 ``` #### keyframe (alias: kf) Set the keyframe interval (GOP size). Lower values improve seek accuracy but increase file size. - Range: 1–120 ``` ?keyframe=30 ``` #### kf_boost Enable adaptive keyframe placement: more frequent keyframes at the start (every 0.5s during first 5s), less frequent afterward (every 2s). Improves initial playback and seek performance. ``` ?kf_boost ``` > Note: `kf_boost` takes priority over `keyframe`. If both are specified, only `kf_boost` is applied. ``` -------------------------------- ### Generate Presigned URL for Upload Source: https://context7.com/defaultuploader/documentation/llms.txt Request a temporary, unauthenticated URL for file uploads. Specify the desired expiration time in seconds using the `expirationIn` query parameter. ```http GET /v1/sign/{SECRET_CLIENT_TOKEN}/{CUSTOM_PATH}?expirationIn=3600 ``` -------------------------------- ### POST /v1/upload Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/rest.mdx Uploads files using a multipart/form-data request. Requires an Authorization header with a secret client token. ```APIDOC ## POST /v1/upload ### Description Uploads files using a multipart/form-data request. Requires an Authorization header with a secret client token. ### Method POST ### Endpoint https://api.defaultuploader.com/v1/upload ### Parameters #### Request Body - **file** (multipart/form-data) - Required - The file to upload. ### Request Example ```bash curl --location 'https://api.defaultuploader.com/v1/upload' \ --header 'Authorization: YOUR_SECRET_CLIENT_TOKEN' \ --form 'file=@"/C:/path_to_file/file_example_JPG_100kB.jpg"' ``` ### Response #### Success Response (200) - **sourceName** (string) - Unique file ID in the bucket. - **src** (string) - File path through API. - **originalSrc** (string) - Direct file path in the bucket. - **originalName** (string) - Original file name. - **s3PathOriginal** (string) - Original file path. - **s3Path** (string) - Derivative file path. - **options** (object) - Internal settings. - **size** (integer) - Size in bytes. - **mimeType** (string) - Media type. - **format** (string) - File format. #### Response Example ```json [ { "sourceName": "7uLbiXh7867H7dEPpsubV9.png", "src": "https://api.defaultuploader.com/v1/image/upload/azxwjk4PCkLTFbuUYiQZ1j/7uLbiXh7867H7dEPpsubV9.png", "originalSrc": "https://hb.vkcs.cloud/defaultuploader/image/png/7uLbiXh7867H7dEPpsubV9.png", "originalName": "dark_theme.png", "s3PathOriginal": "image/png/7uLbiXh7867H7dEPpsubV9.png", "s3Path": "image/png/7uLbiXh7867H7dEPpsubV9.png", "options": {}, "size": 1400308, "mimeType": "image", "format": "png" } ] ``` ``` -------------------------------- ### Basic Image Transformation Request Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Create a new image with a specified width while maintaining the aspect ratio. The API caches the transformed image for future requests with the same parameters. ```http https://api.defaultuploader.com/v1/image/upload/token/sample.jpg?w=100 ``` -------------------------------- ### Delete File (DELETE) Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/rest.mdx Use this endpoint to delete the original file and all its derivative files from storage. ```sh https://api.defaultuploader.com/v1/upload/S3_PATH_ORIGINAL # Requires header — authorization: SECRET_CLIENT_TOKEN ``` -------------------------------- ### Change Video Format Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/video.mdx Specify the desired video format using the `f` parameter (alias for `format`). Supported formats include MP4, MOV, WEBM, and AVI. The default format is MP4. ```text Supported formats MP4, MOV, WEBM, AVI, default is mp4 ``` -------------------------------- ### Asynchronous Transformations Source: https://context7.com/defaultuploader/documentation/llms.txt Upload a file and trigger multiple transformations simultaneously by including the `transforms` form data. This generates all specified transformed versions upon upload. ```APIDOC ## Asynchronous Transformations Upload a file and trigger transformations immediately by passing `transforms` in the form data. ```bash curl --location 'https://api.defaultuploader.com/v1/upload' \ --header 'Authorization: YOUR_SECRET_CLIENT_TOKEN' \ --form 'file=@"/path/to/cat.jpg"' \ --form 'transforms="[\"w=100&h=100\",\"w=200&h=200\"]"' ``` This creates 3 files in the bucket: the original + one file per transformation set. Transformed files are available immediately on subsequent requests without waiting for on-the-fly processing. ``` -------------------------------- ### Change Image Format Source: https://github.com/defaultuploader/documentation/blob/master/src/content/docs/api/transform/image.mdx Use the `f` parameter to change the image format. Supported formats include JPEG, PNG, WebP, AVIF, TIFF, GIF, SVG, and HEIC. ```text Supported formats JPEG, PNG, WebP, AVIF, TIFF, GIF, SVG, HEIC ``` -------------------------------- ### Retrieve and Transform File Source: https://context7.com/defaultuploader/documentation/llms.txt Access a file using its MIME type, client token, and S3 path. Transformations can be applied by adding query parameters to the URL. ```text v1 — API version MIME_TYPE — media type (image, video, audio) CLIENT_TOKEN — token from the dashboard S3_PATH — file path in your S3 storage ```