@quatrain/storage-supabase 1.2.6 → 1.2.8
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.
|
@@ -204,9 +204,30 @@ class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
204
204
|
// TODO: Le client Supabase JS ne supporte pas nativement l'override du ResponseCacheControl dans createSignedUrl.
|
|
205
205
|
// La variable publicCacheDuration / cacheControl n'est donc pas gérée correctement ici pour le moment.
|
|
206
206
|
// Voir si le SDK de Supabase permet de la supporter dans le futur.
|
|
207
|
+
let download = false;
|
|
208
|
+
const isVideoOrAudio = file.contentType && (file.contentType.startsWith('video/') || file.contentType.startsWith('audio/'));
|
|
209
|
+
if (action === 'download') {
|
|
210
|
+
download = true;
|
|
211
|
+
}
|
|
212
|
+
else if (extra.download !== undefined) {
|
|
213
|
+
download = extra.download;
|
|
214
|
+
}
|
|
215
|
+
else if (extra.responseDisposition && extra.responseDisposition.includes('attachment')) {
|
|
216
|
+
const match = extra.responseDisposition.match(/filename="([^"]+)"/);
|
|
217
|
+
if (match && match[1]) {
|
|
218
|
+
download = match[1];
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
download = true;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else if (!isVideoOrAudio) {
|
|
225
|
+
// Default to download=true for non-media files (images, documents) to preserve historical behavior
|
|
226
|
+
download = true;
|
|
227
|
+
}
|
|
207
228
|
const { data, error } = yield this._client
|
|
208
229
|
.from(file.bucket)
|
|
209
|
-
.createSignedUrl(file.ref, expiresIn, { download
|
|
230
|
+
.createSignedUrl(file.ref, expiresIn, { download });
|
|
210
231
|
if (error !== null) {
|
|
211
232
|
throw new Error(`Unable to get signed url: ${error}`);
|
|
212
233
|
}
|
package/package.json
CHANGED
|
@@ -214,9 +214,28 @@ export class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
|
214
214
|
// La variable publicCacheDuration / cacheControl n'est donc pas gérée correctement ici pour le moment.
|
|
215
215
|
// Voir si le SDK de Supabase permet de la supporter dans le futur.
|
|
216
216
|
|
|
217
|
+
let download: boolean | string = false
|
|
218
|
+
const isVideoOrAudio = file.contentType && (file.contentType.startsWith('video/') || file.contentType.startsWith('audio/'))
|
|
219
|
+
|
|
220
|
+
if (action === 'download') {
|
|
221
|
+
download = true
|
|
222
|
+
} else if (extra.download !== undefined) {
|
|
223
|
+
download = extra.download
|
|
224
|
+
} else if (extra.responseDisposition && extra.responseDisposition.includes('attachment')) {
|
|
225
|
+
const match = extra.responseDisposition.match(/filename="([^"]+)"/)
|
|
226
|
+
if (match && match[1]) {
|
|
227
|
+
download = match[1]
|
|
228
|
+
} else {
|
|
229
|
+
download = true
|
|
230
|
+
}
|
|
231
|
+
} else if (!isVideoOrAudio) {
|
|
232
|
+
// Default to download=true for non-media files (images, documents) to preserve historical behavior
|
|
233
|
+
download = true
|
|
234
|
+
}
|
|
235
|
+
|
|
217
236
|
const { data, error } = await this._client
|
|
218
237
|
.from(file.bucket)
|
|
219
|
-
.createSignedUrl(file.ref, expiresIn, { download
|
|
238
|
+
.createSignedUrl(file.ref, expiresIn, { download })
|
|
220
239
|
|
|
221
240
|
if (error !== null) {
|
|
222
241
|
throw new Error(`Unable to get signed url: ${error}`)
|