Skip to content

Commit f0dfca3

Browse files
IMAGES: support for customid in direct upload v2 (cloudflare#6817)
* IMAGES: support for customid in direct upload v2 + undoc direct up v1 * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: marciocloudflare <[email protected]>
1 parent 7087ef0 commit f0dfca3

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

content/images/cloudflare-images/upload-images/custom-id.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ Refer to [Make your first API request](/images/cloudflare-images/api-request/) t
5656
## Custom IDs in delivery URLs
5757

5858
When [serving images](/images/cloudflare-images/serve-images), you can include non URL-encoded Custom IDs directly in the image URLs. However, any `%` characters present in Custom IDs must be encoded to `%25` in the image delivery URLs.
59+
60+
## Custom IDs and private images
61+
62+
Images with a [custom ID](/images/cloudflare-images/upload-images/custom-id/) cannot be made private using [signed URL tokens](/images/cloudflare-images/serve-images/serve-private-images-using-signed-url-tokens/).

content/images/cloudflare-images/upload-images/direct-creator-upload.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ weight: 2
66

77
# Direct Creator Upload
88

9-
The Direct Creator Upload feature in Cloudflare Images lets your users upload pictures with a one-time upload URL. By using Direct Creator Upload, you can accept uploads without exposing [your API key or token](/images/cloudflare-images/api-request/) to the client. It also eliminates the need for an intermediary storage bucket and the storage/egress costs associated with it.
9+
The Direct Creator Upload feature in Cloudflare Images lets your users upload images with a one-time upload URL. By using Direct Creator Upload, you can accept uploads without exposing [your API key or token](/images/cloudflare-images/api-request/) to the client. It also eliminates the need for an intermediary storage bucket and the storage/egress costs associated with it.
1010

11-
To request a one-time upload URL, call the [`direct_upload` endpoint](https://developers.cloudflare.com/api/operations/cloudflare-images-create-authenticated-direct-upload-url) in your back-end (or Worker script):
11+
To request a one-time upload URL, call the [`v2/direct_upload` endpoint](https://developers.cloudflare.com/api/operations/cloudflare-images-create-authenticated-direct-upload-url-v-2) in your back-end (or Worker script):
1212

1313
```bash
1414
curl --request POST \
@@ -24,7 +24,7 @@ You will receive a response similar to this:
2424
{
2525
"result": {
2626
"id": "2cdc28f0-017a-49c4-9ed7-87056c83901",
27-
"uploadURL": "https://upload.imagedelivery.net/2cdc28f0-017a-49c4-9ed7-87056c83901"
27+
"uploadURL": "https://upload.imagedelivery.net/Vi7wi5KSItxGFsWRG2Us6Q/2cdc28f0-017a-49c4-9ed7-87056c83901"
2828
},
2929
"result_info": null,
3030
"success": true,
@@ -35,13 +35,7 @@ You will receive a response similar to this:
3535

3636
In the example above, `id` is a future image identifier that will be uploaded by a creator.
3737

38-
{{<Aside type="note" header="Note">}}
39-
40-
Previously, in version 1 of the `direct_upload` endpoint, the ID was an identifier of a request, not an image. Therefore, there was no way to know if an image had been really uploaded.
41-
42-
{{</Aside>}}
43-
44-
With version 2 of `direct_upload`, a new draft image record is created when you invoke this endpoint. It will not appear on a [list of images](https://developers.cloudflare.com/api/operations/cloudflare-images-list-images), but it is possible to fetch an image record with the provided ID to check its current status. In the example below, `<IMAGE_ID>` is the `id` received from the response when requesting a one-time upload URL with the `direct_upload` endpoint.
38+
A new draft image record is created when you invoke this endpoint. It will not appear on a [list of images](https://developers.cloudflare.com/api/operations/cloudflare-images-list-images/), but it is possible to fetch an image record with the provided ID to check its current status. In the example below, `<IMAGE_ID>` is the `id` received from the response when requesting a one-time upload URL with the `direct_upload` endpoint.
4539

4640
```bash
4741
curl --url https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/images/v1/<IMAGE_ID> \
@@ -99,4 +93,16 @@ To override this option, add the following argument to the cURL command:
9993
--data '{"expiry":"2021-09-14T16:00:00Z"}'
10094
```
10195

102-
The expiry value must be a minimum of two minutes and maximum of six hours in the future.
96+
The expiry value must be a minimum of two minutes and maximum of six hours in the future.
97+
98+
## Direct Creator Upload with Custom ID
99+
100+
You can specify a [custom ID](/images/cloudflare-images/upload-images/custom-id/) when first requesting a one-time upload URL, instead of using the automatically generated ID for your image.
101+
102+
To do so, pass a form field of name `id` with the corresponding custom ID value to the cURL command:
103+
104+
```bash
105+
--form 'id=this/is/my-customid'
106+
```
107+
108+
Note that images with a [custom ID](/images/cloudflare-images/upload-images/custom-id/) cannot be made private with the [signed URL tokens](/images/cloudflare-images/serve-images/serve-private-images-using-signed-url-tokens/) feature (`--requireSignedURLs=true`).

0 commit comments

Comments
 (0)