Class FileUploadParams

  • All Implemented Interfaces:
    io.imagekit.core.Params

    
    public final class FileUploadParams
     implements Params
                        

    ImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time token, signature, and expire from your secure backend using private API. /docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload about how to implement client-side file upload.

    The /docs/api-reference/upload-file/upload-file-v2 enhances security by verifying the entire payload using JWT.

    File size limit \ On the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.

    Version limit \ A file can have a maximum of 100 versions.

    Demo applications

    • A full-fledged upload widget using Uppy, supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.

    • /docs/quick-start-guides for various frameworks and technologies.

    • Constructor Detail

    • Method Detail

      • file

         final InputStream file()

        The API accepts any of the following:

        • Binary data – send the raw bytes as multipart/form-data.

        • HTTP / HTTPS URL – a publicly reachable URL that ImageKit’s servers can fetch.

        • Base64 string – the file encoded as a Base64 data URI or plain Base64.

        When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.

      • fileName

         final String fileName()

        The name with which the file has to be uploaded. The file name can contain:

        • Alphanumeric Characters: a-z, A-Z, 0-9.

        • Special Characters: ., -

        Any other character including space will be replaced by _

      • token

         final Optional<String> token()

        A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. This field is only required for authentication when uploading a file from the client side.

        Note: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field.

      • checks

         final Optional<String> checks()

        Server-side checks to run on the asset. Read more about /docs/api-reference/upload-file/upload-file#upload-api-checks.

      • customCoordinates

         final Optional<String> customCoordinates()

        Define an important area in the image. This is only relevant for image type files.

        • To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format x,y,width,height. For example - 10,10,100,100

        • Can be used with fo-customtransformation.

        • If this field is not specified and the file is overwritten, then customCoordinates will be removed.

      • expire

         final Optional<Long> expire()

        The time until your signature is valid. It must be a Unix time in less than 1 hour into the future. It should be in seconds. This field is only required for authentication when uploading a file from the client side.

      • extensions

         final Optional<List<ExtensionItem>> extensions()

        Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.

      • folder

         final Optional<String> folder()

        The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created.

        The folder name can contain:

        • Alphanumeric Characters: a-z , A-Z , 0-9

        • Special Characters: / , _ , -

        Using multiple / creates a nested folder.

      • isPrivateFile

         final Optional<Boolean> isPrivateFile()

        Whether to mark the file as private or not.

        If true, the file is marked as private and is accessible only using named transformation or signed URL.

      • isPublished

         final Optional<Boolean> isPublished()

        Whether to upload file as published or not.

        If false, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.

        The option to upload in draft state is only available in custom enterprise pricing plans.

      • overwriteAiTags

         final Optional<Boolean> overwriteAiTags()

        If set to true and a file already exists at the exact location, its AITags will be removed. Set overwriteAITags to false to preserve AITags.

      • overwriteCustomMetadata

         final Optional<Boolean> overwriteCustomMetadata()

        If the request does not have customMetadata, and a file already exists at the exact location, existing customMetadata will be removed.

      • overwriteFile

         final Optional<Boolean> overwriteFile()

        If false and useUniqueFileName is also false, and a file already exists at the exact location, upload API will return an error immediately.

      • overwriteTags

         final Optional<Boolean> overwriteTags()

        If the request does not have tags, and a file already exists at the exact location, existing tags will be removed.

      • publicKey

         final Optional<String> publicKey()

        Your ImageKit.io public key. This field is only required for authentication when uploading a file from the client side.

      • signature

         final Optional<String> signature()

        HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn how to create a signature on the page below. This should be in lowercase.

        Signature must be calculated on the server-side. This field is only required for authentication when uploading a file from the client side.

      • tags

         final Optional<List<String>> tags()

        Set the tags while uploading the file. Provide an array of tag strings (e.g. ["tag1", "tag2", "tag3"]). The combined length of all tag characters must not exceed 500, and the % character is not allowed. If this field is not specified and the file is overwritten, the existing tags will be removed.

      • transformation

         final Optional<FileUploadParams.UploadTransformation> transformation()

        Configure pre-processing (pre) and post-processing (post) transformations.

        • pre — applied before the file is uploaded to the Media Library. Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).

        • post — applied immediately after upload. Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.

        You can mix and match any combination of post-processing types.

      • useUniqueFileName

         final Optional<Boolean> useUniqueFileName()

        Whether to use a unique filename for this file or not.

        If true, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.

        If false, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.

      • webhookUrl

         final Optional<String> webhookUrl()

        The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. /docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure about the webhook payload structure.

      • _headers

         Headers _headers()

        The full set of headers in the parameters, including both fixed and additional headers.

      • _queryParams

         QueryParams _queryParams()

        The full set of query params in the parameters, including both fixed and additional query params.