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, andexpirefrom 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classFileUploadParams.BuilderA builder for FileUploadParams.
public final classFileUploadParams.Bodypublic final classFileUploadParams.CustomMetadataJSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.
public final classFileUploadParams.ResponseFieldpublic final classFileUploadParams.UploadTransformationConfigure 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.
-
Method Summary
Modifier and Type Method Description final InputStreamfile()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.
final StringfileName()The name with which the file has to be uploaded. final Optional<String>token()A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. final Optional<String>checks()Server-side checks to run on the asset. final Optional<String>customCoordinates()Define an important area in the image. final Optional<FileUploadParams.CustomMetadata>customMetadata()JSON key-value pairs to associate with the asset. final Optional<String>description()Optional text to describe the contents of the file. final Optional<Long>expire()The time until your signature is valid. final Optional<List<ExtensionItem>>extensions()Array of extensions to be applied to the asset. final Optional<String>folder()The folder path in which the image has to be uploaded. final Optional<Boolean>isPrivateFile()Whether to mark the file as private or not. final Optional<Boolean>isPublished()Whether to upload file as published or not. final Optional<Boolean>overwriteAiTags()If set to trueand a file already exists at the exact location, its AITags will be removed.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.final Optional<Boolean>overwriteFile()If falseanduseUniqueFileNameis alsofalse, and a file already exists at the exact location, upload API will return an error immediately.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.final Optional<String>publicKey()Your ImageKit.io public key. final Optional<List<FileUploadParams.ResponseField>>responseFields()Array of response field keys to include in the API response body. final Optional<String>signature()HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. final Optional<List<String>>tags()Set the tags while uploading the file. final Optional<FileUploadParams.UploadTransformation>transformation()Configure pre-processing ( pre) and post-processing (post) transformations.final Optional<Boolean>useUniqueFileName()Whether to use a unique filename for this file or not. final Optional<String>webhookUrl()The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. final MultipartField<InputStream>_file()Returns the raw multipart value of file. final MultipartField<String>_fileName()Returns the raw multipart value of fileName. final MultipartField<String>_token()Returns the raw multipart value of token. final MultipartField<String>_checks()Returns the raw multipart value of checks. final MultipartField<String>_customCoordinates()Returns the raw multipart value of customCoordinates. final MultipartField<FileUploadParams.CustomMetadata>_customMetadata()Returns the raw multipart value of customMetadata. final MultipartField<String>_description()Returns the raw multipart value of description. final MultipartField<Long>_expire()Returns the raw multipart value of expire. final MultipartField<List<ExtensionItem>>_extensions()Returns the raw multipart value of extensions. final MultipartField<String>_folder()Returns the raw multipart value of folder. final MultipartField<Boolean>_isPrivateFile()Returns the raw multipart value of isPrivateFile. final MultipartField<Boolean>_isPublished()Returns the raw multipart value of isPublished. final MultipartField<Boolean>_overwriteAiTags()Returns the raw multipart value of overwriteAiTags. final MultipartField<Boolean>_overwriteCustomMetadata()Returns the raw multipart value of overwriteCustomMetadata. final MultipartField<Boolean>_overwriteFile()Returns the raw multipart value of overwriteFile. final MultipartField<Boolean>_overwriteTags()Returns the raw multipart value of overwriteTags. final MultipartField<String>_publicKey()Returns the raw multipart value of publicKey. final MultipartField<List<FileUploadParams.ResponseField>>_responseFields()Returns the raw multipart value of responseFields. final MultipartField<String>_signature()Returns the raw multipart value of signature. final MultipartField<List<String>>_tags()Returns the raw multipart value of tags. final MultipartField<FileUploadParams.UploadTransformation>_transformation()Returns the raw multipart value of transformation. final MultipartField<Boolean>_useUniqueFileName()Returns the raw multipart value of useUniqueFileName. final MultipartField<String>_webhookUrl()Returns the raw multipart value of webhookUrl. final Map<String, JsonValue>_additionalBodyProperties()final Headers_additionalHeaders()Additional headers to send with the request. final QueryParams_additionalQueryParams()Additional query param to send with the request. final FileUploadParams.BuildertoBuilder()final Map<String, MultipartField<?>>_body()Headers_headers()The full set of headers in the parameters, including both fixed and additional headers. QueryParams_queryParams()The full set of query params in the parameters, including both fixed and additional query params. Booleanequals(Object other)IntegerhashCode()StringtoString()final static FileUploadParams.Builderbuilder()Returns a mutable builder for constructing an instance of FileUploadParams. -
-
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,100Can be used with fo-customtransformation.
If this field is not specified and the file is overwritten, then customCoordinates will be removed.
-
customMetadata
final Optional<FileUploadParams.CustomMetadata> customMetadata()
JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.
-
description
final Optional<String> description()
Optional text to describe the contents of the file.
-
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-9Special 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
trueand a file already exists at the exact location, its AITags will be removed. SetoverwriteAITagstofalseto 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
falseanduseUniqueFileNameis alsofalse, 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.
-
responseFields
final Optional<List<FileUploadParams.ResponseField>> responseFields()
Array of response field keys to include in the API response body.
-
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.
-
_file
final MultipartField<InputStream> _file()
Returns the raw multipart value of file.
Unlike file, this method doesn't throw if the multipart field has an unexpected type.
-
_fileName
final MultipartField<String> _fileName()
Returns the raw multipart value of fileName.
Unlike fileName, this method doesn't throw if the multipart field has an unexpected type.
-
_token
final MultipartField<String> _token()
Returns the raw multipart value of token.
Unlike token, this method doesn't throw if the multipart field has an unexpected type.
-
_checks
final MultipartField<String> _checks()
Returns the raw multipart value of checks.
Unlike checks, this method doesn't throw if the multipart field has an unexpected type.
-
_customCoordinates
final MultipartField<String> _customCoordinates()
Returns the raw multipart value of customCoordinates.
Unlike customCoordinates, this method doesn't throw if the multipart field has an unexpected type.
-
_customMetadata
final MultipartField<FileUploadParams.CustomMetadata> _customMetadata()
Returns the raw multipart value of customMetadata.
Unlike customMetadata, this method doesn't throw if the multipart field has an unexpected type.
-
_description
final MultipartField<String> _description()
Returns the raw multipart value of description.
Unlike description, this method doesn't throw if the multipart field has an unexpected type.
-
_expire
final MultipartField<Long> _expire()
Returns the raw multipart value of expire.
Unlike expire, this method doesn't throw if the multipart field has an unexpected type.
-
_extensions
final MultipartField<List<ExtensionItem>> _extensions()
Returns the raw multipart value of extensions.
Unlike extensions, this method doesn't throw if the multipart field has an unexpected type.
-
_folder
final MultipartField<String> _folder()
Returns the raw multipart value of folder.
Unlike folder, this method doesn't throw if the multipart field has an unexpected type.
-
_isPrivateFile
final MultipartField<Boolean> _isPrivateFile()
Returns the raw multipart value of isPrivateFile.
Unlike isPrivateFile, this method doesn't throw if the multipart field has an unexpected type.
-
_isPublished
final MultipartField<Boolean> _isPublished()
Returns the raw multipart value of isPublished.
Unlike isPublished, this method doesn't throw if the multipart field has an unexpected type.
-
_overwriteAiTags
final MultipartField<Boolean> _overwriteAiTags()
Returns the raw multipart value of overwriteAiTags.
Unlike overwriteAiTags, this method doesn't throw if the multipart field has an unexpected type.
-
_overwriteCustomMetadata
final MultipartField<Boolean> _overwriteCustomMetadata()
Returns the raw multipart value of overwriteCustomMetadata.
Unlike overwriteCustomMetadata, this method doesn't throw if the multipart field has an unexpected type.
-
_overwriteFile
final MultipartField<Boolean> _overwriteFile()
Returns the raw multipart value of overwriteFile.
Unlike overwriteFile, this method doesn't throw if the multipart field has an unexpected type.
-
_overwriteTags
final MultipartField<Boolean> _overwriteTags()
Returns the raw multipart value of overwriteTags.
Unlike overwriteTags, this method doesn't throw if the multipart field has an unexpected type.
-
_publicKey
final MultipartField<String> _publicKey()
Returns the raw multipart value of publicKey.
Unlike publicKey, this method doesn't throw if the multipart field has an unexpected type.
-
_responseFields
final MultipartField<List<FileUploadParams.ResponseField>> _responseFields()
Returns the raw multipart value of responseFields.
Unlike responseFields, this method doesn't throw if the multipart field has an unexpected type.
-
_signature
final MultipartField<String> _signature()
Returns the raw multipart value of signature.
Unlike signature, this method doesn't throw if the multipart field has an unexpected type.
-
_tags
final MultipartField<List<String>> _tags()
Returns the raw multipart value of tags.
Unlike tags, this method doesn't throw if the multipart field has an unexpected type.
-
_transformation
final MultipartField<FileUploadParams.UploadTransformation> _transformation()
Returns the raw multipart value of transformation.
Unlike transformation, this method doesn't throw if the multipart field has an unexpected type.
-
_useUniqueFileName
final MultipartField<Boolean> _useUniqueFileName()
Returns the raw multipart value of useUniqueFileName.
Unlike useUniqueFileName, this method doesn't throw if the multipart field has an unexpected type.
-
_webhookUrl
final MultipartField<String> _webhookUrl()
Returns the raw multipart value of webhookUrl.
Unlike webhookUrl, this method doesn't throw if the multipart field has an unexpected type.
-
_additionalBodyProperties
final Map<String, JsonValue> _additionalBodyProperties()
-
_additionalHeaders
final Headers _additionalHeaders()
Additional headers to send with the request.
-
_additionalQueryParams
final QueryParams _additionalQueryParams()
Additional query param to send with the request.
-
toBuilder
final FileUploadParams.Builder toBuilder()
-
_body
final Map<String, MultipartField<?>> _body()
-
_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.
-
builder
final static FileUploadParams.Builder builder()
Returns a mutable builder for constructing an instance of FileUploadParams.
The following fields are required:
.file() .fileName()
-
-
-