Custom ID
You can use a custom path to upload images to Cloudflare Images, instead of the path automatically generated by Cloudflare Images’ Universal Unique Identifier (UUID). The custom path has the following properties:
- Could be up to 1024 characters long.
- Could include any number of subpaths.
- Supports the UTF-8 encoding standard for characters.
Below is an example of the custom ID feature using upload via URL:
curl --request POST https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/images/v1 \ --header 'Authorization: Bearer :token' \ --form 'url=https://<REMOTE_PATH_TO_IMAGE>' \ --form 'id=<PATH_TO_YOUR_IMAGE>'
You can also use the custom ID feature with direct file upload:
curl --request POST \ https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/images/v1 \ --header 'Authorization: Bearer :token' \ --form 'file=@./<PATH_TO_YOUR_IMAGE>' \ --form 'id=<PATH_TO_YOUR_IMAGE>'
You will then receive a response similar to this:
{ "result": { "id": "<PATH_TO_YOUR_IMAGE>", "filename": "<YOUR_IMAGE>", "uploaded": "2022-04-20T09:51:09.559Z", "requireSignedURLs": false, "variants": ["https://imagedelivery.net/Vi7wi5KSItxGFsWRG2Us6Q/<PATH_TO_YOUR_IMAGE>/public"] }, "result_info": null, "success": true, "errors": [], "messages": []
}
You can use the custom ID feature with the ability to serve images from custom domains for added flexibility.