1+ diff --git a/dist/adapter.d.ts b/dist/adapter.d.ts
2+ index e4921574d152b98a79bc5319634e36af4fb1ab39..4e45a6b1d6a3b1a4dbb6cf192882a50d55048323 100644
3+ --- a/dist/adapter.d.ts
4+ +++ b/dist/adapter.d.ts
5+ @@ -2,12 +2,13 @@ import type { Adapter, ClientUploadsConfig } from '@payloadcms/plugin-cloud-stor
6+ interface CreateVercelBlobAdapterArgs {
7+ access: 'public';
8+ addRandomSuffix?: boolean;
9+ + allowOverwrite?: boolean;
10+ baseUrl: string;
11+ cacheControlMaxAge: number;
12+ clientUploads?: ClientUploadsConfig;
13+ token: string;
14+ useCompositePrefixes?: boolean;
15+ }
16+ - export declare function createVercelBlobAdapter({ access, addRandomSuffix, baseUrl, cacheControlMaxAge, clientUploads, token, useCompositePrefixes, }: CreateVercelBlobAdapterArgs): Adapter;
17+ + export declare function createVercelBlobAdapter({ access, addRandomSuffix, allowOverwrite, baseUrl, cacheControlMaxAge, clientUploads, token, useCompositePrefixes, }: CreateVercelBlobAdapterArgs): Adapter;
18+ export {};
19+ //# sourceMappingURL=adapter.d.ts.map
20+ \ No newline at end of file
21+ diff --git a/dist/adapter.js b/dist/adapter.js
22+ index 7c08de8d0b581327114f868ae69858cccef120ec..2790699d38440430e6d0e0a463e967edd150aa3a 100644
23+ --- a/dist/adapter.js
24+ +++ b/dist/adapter.js
25+ @@ -2,7 +2,7 @@ import { deleteFile } from './deleteFile.js';
26+ import { generateURL } from './generateURL.js';
27+ import { getFile } from './getFile.js';
28+ import { uploadFile } from './uploadFile.js';
29+ - export function createVercelBlobAdapter({ access, addRandomSuffix, baseUrl, cacheControlMaxAge, clientUploads, token, useCompositePrefixes = false }) {
30+ + export function createVercelBlobAdapter({ access, addRandomSuffix, allowOverwrite, baseUrl, cacheControlMaxAge, clientUploads, token, useCompositePrefixes = false }) {
31+ return ({ collection, prefix = '' })=>({
32+ name: 'vercel-blob',
33+ clientUploads,
34+ @@ -25,6 +25,7 @@ export function createVercelBlobAdapter({ access, addRandomSuffix, baseUrl, cach
35+ const result = await uploadFile({
36+ access,
37+ addRandomSuffix,
38+ + allowOverwrite,
39+ buffer,
40+ cacheControlMaxAge,
41+ collectionPrefix: prefix,
142diff --git a/dist/client/VercelBlobClientUploadHandler.d.ts b/dist/client/VercelBlobClientUploadHandler.d.ts
2- index 984feebe49e7bfaabd0294eebaa9415e09e0e5cd..18285f61580c050750d6312d12a8cdfb5d4ba6c8 100644
43+ index b3b021ebd932ab8c6bb0b5abf829dae0f91a2396..3269e5bd16056ec46f57809166b3e7cc28a78e3e 100644
344--- a/dist/client/VercelBlobClientUploadHandler.d.ts
445+++ b/dist/client/VercelBlobClientUploadHandler.d.ts
546@@ -1,5 +1,6 @@
647 export type VercelBlobClientUploadHandlerExtra = {
748 addRandomSuffix: boolean;
849+ allowOverwrite: boolean;
9- baseURL: string;
10- prefix: string;
50+ useCompositePrefixes: boolean;
1151 };
12- diff --git a/dist/client/VercelBlobClientUploadHandler.js b/dist/client/VercelBlobClientUploadHandler.js
13- index 94a3512c0436805acba26910adb595cf970f4961..cda0b0aea5769c0522b7e9d609d9b919f89a43aa 100644
14- --- a/dist/client/VercelBlobClientUploadHandler.js
15- +++ b/dist/client/VercelBlobClientUploadHandler.js
16- @@ -3,7 +3,7 @@ import { createClientUploadHandler } from '@payloadcms/plugin-cloud-storage/clie
17- import { upload } from '@vercel/blob/client';
18- import { formatAdminURL } from 'payload/shared';
19- export const VercelBlobClientUploadHandler = createClientUploadHandler({
20- - handler: async ({ apiRoute, collectionSlug, extra: { addRandomSuffix, baseURL, prefix = '' }, file, serverHandlerPath, serverURL, updateFilename })=>{
21- + handler: async ({ apiRoute, collectionSlug, extra: { addRandomSuffix, allowOverwrite, baseURL, prefix = '' }, file, serverHandlerPath, serverURL, updateFilename })=>{
22- const endpointRoute = formatAdminURL({
23- apiRoute,
24- path: serverHandlerPath,
52+ export declare const VercelBlobClientUploadHandler: ({ children, collectionSlug, enabled, extra, prefix, serverHandlerPath, }: {
2553diff --git a/dist/getClientUploadRoute.d.ts b/dist/getClientUploadRoute.d.ts
2654index b0d9157554801e9a873ad09c1ace7c6c5db43a90..519f19e05145f5aaabd7afe8571149b529019b50 100644
2755--- a/dist/getClientUploadRoute.d.ts
@@ -60,39 +88,8 @@ index e11cf568867309efcb243fab490a33c6b01c46a8..bfeeee12b5180db867576f1a33738ebd
6088 cacheControlMaxAge
6189 });
6290 },
63- diff --git a/dist/handleUpload.d.ts b/dist/handleUpload.d.ts
64- index 74b7b972fc9dbeffb7a2c79c8b472c831e61a670..404b4e4f2adc0d8f0180fae9428444232a2e4d6f 100644
65- --- a/dist/handleUpload.d.ts
66- +++ b/dist/handleUpload.d.ts
67- @@ -4,6 +4,6 @@ type HandleUploadArgs = {
68- baseUrl: string;
69- prefix?: string;
70- } & Omit<VercelBlobStorageOptions, 'collections'>;
71- - export declare const getHandleUpload: ({ access, addRandomSuffix, baseUrl, cacheControlMaxAge, prefix, token, }: HandleUploadArgs) => HandleUpload;
72- + export declare const getHandleUpload: ({ access, addRandomSuffix, allowOverwrite, baseUrl, cacheControlMaxAge, prefix, token, }: HandleUploadArgs) => HandleUpload;
73- export {};
74- //# sourceMappingURL=handleUpload.d.ts.map
75- \ No newline at end of file
76- diff --git a/dist/handleUpload.js b/dist/handleUpload.js
77- index db797445156822d2a2a0024b303df940b446e4c2..eedefda709bf53e7f0b4bd2f1b0cdc81e5267c52 100644
78- --- a/dist/handleUpload.js
79- +++ b/dist/handleUpload.js
80- @@ -1,11 +1,12 @@
81- import { put } from '@vercel/blob';
82- import path from 'path';
83- - export const getHandleUpload = ({ access = 'public', addRandomSuffix, baseUrl, cacheControlMaxAge, prefix = '', token })=>{
84- + export const getHandleUpload = ({ access = 'public', addRandomSuffix, allowOverwrite, baseUrl, cacheControlMaxAge, prefix = '', token })=>{
85- return async ({ data, file: { buffer, filename, mimeType } })=>{
86- const fileKey = path.posix.join(data.prefix || prefix, filename);
87- const result = await put(fileKey, buffer, {
88- access,
89- addRandomSuffix,
90- + allowOverwrite,
91- cacheControlMaxAge,
92- contentType: mimeType,
93- token
9491diff --git a/dist/index.d.ts b/dist/index.d.ts
95- index 8949c2db42d2657bdd7a72e1476420ce9766ea23..1edaf94546ad7876d4577a7150ed3b85f14f1585 100644
92+ index 42bc409877a795be084492014f7818286c4f92ff..987f1a5c59a936dd0b938d601ddeeaa2f3aef6fb 100644
9693--- a/dist/index.d.ts
9794+++ b/dist/index.d.ts
9895@@ -14,6 +14,13 @@ export type VercelBlobStorageOptions = {
@@ -110,24 +107,23 @@ index 8949c2db42d2657bdd7a72e1476420ce9766ea23..1edaf94546ad7876d4577a7150ed3b85
110107 * When enabled, fields (like the prefix field) will always be inserted into
111108 * the collection schema regardless of whether the plugin is enabled. This
112109diff --git a/dist/index.js b/dist/index.js
113- index 7c56ee05908afb9dfb3bfa20f2a5b9ed3e4cca69..7ca12e268e986d595c86840cce40dd1ae5949021 100644
110+ index 90888ac80eda32c21fae7f511296dbff1f93c9f8..3680d809ce6e4d4776cf2c173c251145c32bd7c2 100644
114111--- a/dist/index.js
115112+++ b/dist/index.js
116- @@ -8 ,6 +8 ,7 @@ import { getStaticHandler } from './staticHandler .js';
113+ @@ -5 ,6 +5 ,7 @@ import { getClientUploadRoute } from './getClientUploadRoute .js';
117114 const defaultUploadOptions = {
118115 access: 'public',
119116 addRandomSuffix: false,
120117+ allowOverwrite: false,
121118 cacheControlMaxAge: 60 * 60 * 24 * 365,
122119 enabled: true
123120 };
124- @@ -32,12 +33,14 @@ export const vercelBlobStorage = (options)=>(incomingConfig)=>{
121+ @@ -29,11 +30,13 @@ export const vercelBlobStorage = (options)=>(incomingConfig)=>{
125122 enabled: !isPluginDisabled && Boolean(options.clientUploads),
126- extraClientHandlerProps: (collection )=>({
123+ extraClientHandlerProps: ()=>({
127124 addRandomSuffix: !!optionsWithDefaults.addRandomSuffix,
128125+ allowOverwrite: !!optionsWithDefaults.allowOverwrite,
129- baseURL: baseUrl,
130- prefix: typeof collection === 'object' && collection.prefix && `${collection.prefix}/` || ''
126+ useCompositePrefixes: !!options.useCompositePrefixes
131127 }),
132128 serverHandler: getClientUploadRoute({
133129 access: typeof options.clientUploads === 'object' ? options.clientUploads.access : undefined,
@@ -136,20 +132,53 @@ index 7c56ee05908afb9dfb3bfa20f2a5b9ed3e4cca69..7ca12e268e986d595c86840cce40dd1a
136132 cacheControlMaxAge: options.cacheControlMaxAge,
137133 token: options.token ?? ''
138134 }),
139- @@ -96,7 +99,7 @@ export const vercelBlobStorage = (options)=>(incomingConfig)=>{
140- };
141- function vercelBlobStorageInternal(options) {
142- return ({ collection, prefix })=>{
143- - const { access, addRandomSuffix, baseUrl, cacheControlMaxAge, clientUploads, token } = options;
144- + const { access, addRandomSuffix, allowOverwrite, baseUrl, cacheControlMaxAge, clientUploads, token } = options;
145- if (!token) {
146- throw new Error('Vercel Blob storage token is required');
147- }
148- @@ -115,6 +118,7 @@ function vercelBlobStorageInternal(options) {
149- handleUpload: getHandleUpload({
150- access,
151- addRandomSuffix,
152- + allowOverwrite,
153- baseUrl,
154- cacheControlMaxAge,
155- prefix,
135+ @@ -61,6 +64,7 @@ export const vercelBlobStorage = (options)=>(incomingConfig)=>{
136+ const adapter = createVercelBlobAdapter({
137+ access: optionsWithDefaults.access ?? 'public',
138+ addRandomSuffix: optionsWithDefaults.addRandomSuffix,
139+ + allowOverwrite: optionsWithDefaults.allowOverwrite,
140+ baseUrl,
141+ cacheControlMaxAge: optionsWithDefaults.cacheControlMaxAge ?? 60 * 60 * 24 * 365,
142+ clientUploads: optionsWithDefaults.clientUploads,
143+ diff --git a/dist/uploadFile.d.ts b/dist/uploadFile.d.ts
144+ index 4edd33ec221160cd21cd70bdcc073a8f9de726dc..ede921dc06cbf0085d19a03771c93066d3bbf469 100644
145+ --- a/dist/uploadFile.d.ts
146+ +++ b/dist/uploadFile.d.ts
147+ @@ -1,6 +1,7 @@
148+ interface UploadFileArgs {
149+ access: 'public';
150+ addRandomSuffix?: boolean;
151+ + allowOverwrite?: boolean;
152+ buffer: Buffer;
153+ cacheControlMaxAge?: number;
154+ collectionPrefix?: string;
155+ @@ -13,6 +14,6 @@ interface UploadFileArgs {
156+ interface UploadFileResult {
157+ filename?: string;
158+ }
159+ - export declare function uploadFile({ access, addRandomSuffix, buffer, cacheControlMaxAge, collectionPrefix, docPrefix, filename, mimeType, token, useCompositePrefixes, }: UploadFileArgs): Promise<UploadFileResult>;
160+ + export declare function uploadFile({ access, addRandomSuffix, allowOverwrite, buffer, cacheControlMaxAge, collectionPrefix, docPrefix, filename, mimeType, token, useCompositePrefixes, }: UploadFileArgs): Promise<UploadFileResult>;
161+ export {};
162+ //# sourceMappingURL=uploadFile.d.ts.map
163+ \ No newline at end of file
164+ diff --git a/dist/uploadFile.js b/dist/uploadFile.js
165+ index b3b6bf4b5d407cd5cf44a84c071a282d00959819..8a7d5e7dbe067f05a5ab53b2104cec731543c5a7 100644
166+ --- a/dist/uploadFile.js
167+ +++ b/dist/uploadFile.js
168+ @@ -1,7 +1,7 @@
169+ import { getFileKey } from '@payloadcms/plugin-cloud-storage/utilities';
170+ import { put } from '@vercel/blob';
171+ import path from 'path';
172+ - export async function uploadFile({ access, addRandomSuffix, buffer, cacheControlMaxAge, collectionPrefix = '', docPrefix, filename, mimeType, token, useCompositePrefixes = false }) {
173+ + export async function uploadFile({ access, addRandomSuffix, allowOverwrite, buffer, cacheControlMaxAge, collectionPrefix = '', docPrefix, filename, mimeType, token, useCompositePrefixes = false }) {
174+ const { fileKey } = getFileKey({
175+ collectionPrefix,
176+ docPrefix,
177+ @@ -11,6 +11,7 @@ export async function uploadFile({ access, addRandomSuffix, buffer, cacheControl
178+ const result = await put(fileKey, buffer, {
179+ access,
180+ addRandomSuffix,
181+ + allowOverwrite,
182+ cacheControlMaxAge,
183+ contentType: mimeType,
184+ token
0 commit comments