You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/blob/src/index.ts
+88-3Lines changed: 88 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -41,11 +41,21 @@ export type { PutCommandOptions };
41
41
* Uploads a blob into your store from your server.
42
42
* Detailed documentation can be found here: https://vercel.com/docs/vercel-blob/using-blob-sdk#upload-a-blob
43
43
*
44
-
* If you want to upload from the browser directly, check out the documentation forAclient uploads: https://vercel.com/docs/vercel-blob/using-blob-sdk#client-uploads
44
+
* If you want to upload from the browser directly, or if you're hitting Vercel upload limits, check out the documentation for client uploads: https://vercel.com/docs/vercel-blob/using-blob-sdk#client-uploads
45
45
*
46
-
* @param pathname - The pathname to upload the blob to, including the extension. This will influence the url of your blob like https://$storeId.public.blob.vercel-storage.com/$pathname.
46
+
* @param pathname - The pathname to upload the blob to, including the extension. This will influence the URL of your blob like https://$storeId.public.blob.vercel-storage.com/$pathname.
47
47
* @param body - The content of your blob, can be a: string, File, Blob, Buffer or Stream. We support almost everything fetch supports: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit#body.
48
-
* @param options - Additional options like `token` or `contentType`.
* - access - (Required) Must be 'public' as blobs are publicly accessible.
50
+
* - addRandomSuffix - (Optional) A boolean specifying whether to add a random suffix to the pathname. It defaults to false. We recommend using this option to ensure there are no conflicts in your blob filenames.
51
+
* - allowOverwrite - (Optional) A boolean to allow overwriting blobs. By default an error will be thrown if you try to overwrite a blob by using the same pathname for multiple blobs.
52
+
* - contentType - (Optional) A string indicating the media type. By default, it's extracted from the pathname's extension.
53
+
* - cacheControlMaxAge - (Optional) A number in seconds to configure how long Blobs are cached. Defaults to one month. Cannot be set to a value lower than 1 minute.
54
+
* - token - (Optional) A string specifying the token to use when making requests. It defaults to process.env.BLOB_READ_WRITE_TOKEN when deployed on Vercel.
55
+
* - multipart - (Optional) Whether to use multipart upload for large files. It will split the file into multiple parts, upload them in parallel and retry failed parts.
56
+
* - abortSignal - (Optional) AbortSignal to cancel the operation.
* Creates a multipart upload. This is the first step in the manual multipart upload process.
100
+
*
101
+
* @param pathname - A string specifying the path inside the blob store. This will be the base value of the return URL and includes the filename and extension.
* - access - (Required) Must be 'public' as blobs are publicly accessible.
104
+
* - addRandomSuffix - (Optional) A boolean specifying whether to add a random suffix to the pathname. It defaults to true.
105
+
* - allowOverwrite - (Optional) A boolean to allow overwriting blobs. By default an error will be thrown if you try to overwrite a blob by using the same pathname for multiple blobs.
106
+
* - contentType - (Optional) The media type for the file. If not specified, it's derived from the file extension. Falls back to application/octet-stream when no extension exists or can't be matched.
107
+
* - cacheControlMaxAge - (Optional) A number in seconds to configure the edge and browser cache. Defaults to one year.
108
+
* - token - (Optional) A string specifying the token to use when making requests. It defaults to process.env.BLOB_READ_WRITE_TOKEN when deployed on Vercel.
109
+
* - abortSignal - (Optional) AbortSignal to cancel the operation.
110
+
* @returns A promise that resolves to an object containing:
111
+
* - key: A string that identifies the blob object.
112
+
* - uploadId: A string that identifies the multipart upload. Both are needed for subsequent uploadPart calls.
* Creates a multipart uploader that simplifies the multipart upload process.
126
+
* This is a wrapper around the manual multipart upload process that provides a more convenient API.
127
+
*
128
+
* @param pathname - A string specifying the path inside the blob store. This will be the base value of the return URL and includes the filename and extension.
* - access - (Required) Must be 'public' as blobs are publicly accessible.
131
+
* - addRandomSuffix - (Optional) A boolean specifying whether to add a random suffix to the pathname. It defaults to true.
132
+
* - allowOverwrite - (Optional) A boolean to allow overwriting blobs. By default an error will be thrown if you try to overwrite a blob by using the same pathname for multiple blobs.
133
+
* - contentType - (Optional) The media type for the file. If not specified, it's derived from the file extension. Falls back to application/octet-stream when no extension exists or can't be matched.
134
+
* - cacheControlMaxAge - (Optional) A number in seconds to configure the edge and browser cache. Defaults to one year.
135
+
* - token - (Optional) A string specifying the token to use when making requests. It defaults to process.env.BLOB_READ_WRITE_TOKEN when deployed on Vercel.
136
+
* - abortSignal - (Optional) AbortSignal to cancel the operation.
137
+
* @returns A promise that resolves to an uploader object with the following properties and methods:
138
+
* - key: A string that identifies the blob object.
139
+
* - uploadId: A string that identifies the multipart upload.
140
+
* - uploadPart: A method to upload a part of the file.
141
+
* - complete: A method to complete the multipart upload process.
* Used as part of the manual multipart upload process.
158
+
*
159
+
* @param pathname - Same value as the pathname parameter passed to createMultipartUpload. This will influence the final URL of your blob.
160
+
* @param body - A blob object as ReadableStream, String, ArrayBuffer or Blob based on these supported body types. Each part must be a minimum of 5MB, except the last one which can be smaller.
* - access - (Required) Must be 'public' as blobs are publicly accessible.
163
+
* - uploadId - (Required) A string returned from createMultipartUpload which identifies the multipart upload.
164
+
* - key - (Required) A string returned from createMultipartUpload which identifies the blob object.
165
+
* - partNumber - (Required) A number identifying which part is uploaded (1-based index).
166
+
* - contentType - (Optional) The media type for the blob. By default, it's derived from the pathname.
167
+
* - token - (Optional) A string specifying the token to use when making requests. It defaults to process.env.BLOB_READ_WRITE_TOKEN when deployed on Vercel.
168
+
* - addRandomSuffix - (Optional) A boolean specifying whether to add a random suffix to the pathname.
169
+
* - allowOverwrite - (Optional) A boolean to allow overwriting blobs.
170
+
* - cacheControlMaxAge - (Optional) A number in seconds to configure how long Blobs are cached.
171
+
* - abortSignal - (Optional) AbortSignal to cancel the running request.
* @returns A promise that resolves to the uploaded part information containing etag and partNumber, which will be needed for the completeMultipartUpload call.
* Completes a multipart upload by combining all uploaded parts.
188
+
* This is the final step in the manual multipart upload process.
189
+
*
190
+
* @param pathname - Same value as the pathname parameter passed to createMultipartUpload.
191
+
* @param parts - An array containing all the uploaded parts information from previous uploadPart calls. Each part must have properties etag and partNumber.
* - access - (Required) Must be 'public' as blobs are publicly accessible.
194
+
* - uploadId - (Required) A string returned from createMultipartUpload which identifies the multipart upload.
195
+
* - key - (Required) A string returned from createMultipartUpload which identifies the blob object.
196
+
* - contentType - (Optional) The media type for the file. If not specified, it's derived from the file extension.
197
+
* - token - (Optional) A string specifying the token to use when making requests. It defaults to process.env.BLOB_READ_WRITE_TOKEN when deployed on Vercel.
198
+
* - addRandomSuffix - (Optional) A boolean specifying whether to add a random suffix to the pathname. It defaults to true.
199
+
* - allowOverwrite - (Optional) A boolean to allow overwriting blobs.
200
+
* - cacheControlMaxAge - (Optional) A number in seconds to configure the edge and browser cache. Defaults to one year.
201
+
* - abortSignal - (Optional) AbortSignal to cancel the operation.
202
+
* @returns A promise that resolves to the finalized blob information, including pathname, contentType, contentDisposition, url, and downloadUrl.
0 commit comments