nuxt-upload-kit 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -190,7 +190,7 @@ export declare const useUploadKit: <TUploadResult = any>(_options?: UploadOption
|
|
|
190
190
|
onGetRemoteFile: (fn: GetRemoteFileFn) => void;
|
|
191
191
|
onUpload: (fn: UploadFn<TUploadResult>) => void;
|
|
192
192
|
removeFile: (fileId: string, removeOptions?: {
|
|
193
|
-
deleteFromStorage?:
|
|
193
|
+
deleteFromStorage?: "always" | "never" | "local-only";
|
|
194
194
|
}) => Promise<void>;
|
|
195
195
|
removeFiles: (fileIds: string[]) => ({
|
|
196
196
|
source: "local";
|
|
@@ -258,10 +258,22 @@ This is deprecated. Use the 'storage' option instead:
|
|
|
258
258
|
return addedFiles;
|
|
259
259
|
};
|
|
260
260
|
const removeFile = async (fileId, removeOptions) => {
|
|
261
|
-
const { deleteFromStorage =
|
|
261
|
+
const { deleteFromStorage = "always" } = removeOptions ?? {};
|
|
262
262
|
const file = files.value.find((f) => f.id === fileId);
|
|
263
263
|
if (!file) return;
|
|
264
|
-
|
|
264
|
+
let shouldDelete;
|
|
265
|
+
switch (deleteFromStorage) {
|
|
266
|
+
case "always":
|
|
267
|
+
shouldDelete = true;
|
|
268
|
+
break;
|
|
269
|
+
case "never":
|
|
270
|
+
shouldDelete = false;
|
|
271
|
+
break;
|
|
272
|
+
case "local-only":
|
|
273
|
+
shouldDelete = file.source === "local";
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
if (shouldDelete && file.remoteUrl) {
|
|
265
277
|
const storagePlugin = getStoragePlugin();
|
|
266
278
|
if (storagePlugin?.hooks.remove) {
|
|
267
279
|
try {
|
package/package.json
CHANGED