Use FormData. (multipart/form-data)
A string representing the name of the file. (without extension) Must adhere to the a to z, A to Z, 0 to 9, and _ pattern. (3 to 32 characters)
A string representing the prefix for the file. Must adhere to the a to z, A to Z, 0 to 9, and _ pattern. (3 to 32 characters)
A number indicating the expiration period of the file, ranging from 1 to 365 days.
Set to true if a security hash is required.
Set to true if the file should be set for automatic download.
Response
Indicates whether the call was successful. “success” if successful, “error” if not.
The ID of the uploaded file.
The name of the uploaded file.
The size of the uploaded file, in bytes.
The URL of the uploaded file. (File distributed in Square Cloud CDN)
{
"status" : "success" ,
"response" : {
"id" : "3155597145698959364/test_lxch4k7y-07ee.png" ,
"name" : "test" ,
"size" : 416230 ,
"url" : "https://public-blob.squarecloud.dev/3155597145698959364/test_lxch4k7y-07ee.png"
}
}
Troubleshooting
400 Status Code
401 Status Code
NAME
PREFIX
EXPIRE
SECURITY_HASH
AUTO_DOWNLOAD
// The provided object name is invalid.
// Must adhere to the a to z, A to Z, 0 to 9, and _ pattern.
{
"status" : "error" ,
"code" : "INVALID_OBJECT_NAME"
}
The current maximum file size is 100MB. In the future, we plan to increase it to 10GB. For now, the limit is 100MB due to technical and load-balancing constraints.
INVALID_FILE
FILETYPE
FILE_TOO_SMALL
FILE_TOO_LARGE
// The provided file is invalid.
{
"status" : "error" ,
"code" : "INVALID_FILE"
}