SDK JavaScript : référence de stockage
Chaque méthode qui gère les buckets et les objets, avec sa signature.
Cette page a été traduite automatiquement. La version anglaise fait foi.
Service de stockage#
| Méthode | Descriptif |
|---|---|
from(bucketId: string): StorageBucketClient | Renvoie un client limité à un compartiment spécifique (parité DX Supabase). |
listBuckets(): Promise<AuraResponse<StorageBucket[]>> | Répertoriez les compartiments du projet. |
getBucket(id: string): Promise<AuraResponse<StorageBucket>> | Lit un compartiment par son identifiant. |
createBucket(name: string, options?: { public?: boolean; fileSizeLimit?: number; allowedMimeTypes?: string[]; }): Promise<AuraResponse<StorageBucket>> | Créez un compartiment. public (par défaut false) rend ses objets lisibles sans authentification ; fileSizeLimit (en octets) et allowedMimeTypes limitent les fichiers acceptés. |
updateBucket(id: string, options?: { public?: boolean; fileSizeLimit?: number; allowedMimeTypes?: string[]; }): Promise<AuraResponse<StorageBucket>> | Met à jour un bucket existant (mise à jour PARTIELLE : seuls les champs fournis sont envoyés). |
deleteBucket(id: string): Promise<AuraResponse<null>> | Supprime un bucket par son identifiant. |
upload(bucketId: string, path: string, file: Blob | File | ArrayBuffer | Uint8Array, options?: { contentType?: string; upsert?: boolean; metadata?: Record<string, string>; authToken?: string; signal?: AbortSignal; onUploadProgress?: (progress: UploadProgressEvent) => void; }): Promise<AuraResponse<UploadResult>> | Téléchargez un fichier dans un bucket. |
uploadToSignedUrl(signedUrl: string, file: Blob | File | ArrayBuffer | Uint8Array, options?: { contentType?: string; signal?: AbortSignal; onUploadProgress?: (progress: UploadProgressEvent) => void; }): Promise<AuraResponse<UploadResult>> | Téléchargement direct vers une URL pré-signée (createSignedUploadUrl). |
download(bucketId: string, path: string, options?: { transform?: ImageTransform; download?: boolean | string; }): BlobDownloadBuilder | Téléchargement paresseux d'un fichier. |
list(bucketId: string, pathOrOptions?: string | { prefix?: string; limit?: number; offset?: number; cursor?: string; authToken?: string; }, maybeOptions?: { prefix?: string; limit?: number; offset?: number; cursor?: string; authToken?: string; }): Promise<AuraResponse<FileEntry[]>> | Répertoriez les fichiers dans un bucket. |
remove(bucketId: string, paths: string[], options?: { permanent?: boolean; authToken?: string; }): Promise<AuraResponse<null>> | Supprimez un ou plusieurs fichiers d'un compartiment. |
listTrash(bucketId: string, options?: { prefix?: string; authToken?: string; }): Promise<AuraResponse<Array<{ key: string; size: number | null; content_type: string | null; deleted_at: string; }>>> | Répertorie les objets placés dans la corbeille (suppression logicielle) d'un bucket. |
restore(bucketId: string, path: string, options?: { authToken?: string; }): Promise<AuraResponse<{ restored: boolean; key: string; }>> | Restaure un objet placé dans la corbeille (soft-delete). |
copy(bucketId: string, fromPath: string, toPath: string, options?: { destinationBucket?: string; authToken?: string; }): Promise<AuraResponse<{ key: string; }>> | Copiez un fichier dans un compartiment. |
move(bucketId: string, fromPath: string, toPath: string, options?: { destinationBucket?: string; authToken?: string; }): Promise<AuraResponse<{ key: string; }>> | Déplacer/renommer un fichier dans un bucket ou vers un autre bucket. |
getMetadata(bucketId: string, path: string, options?: { authToken?: string; }): Promise<AuraResponse<ObjectMeta>> | Obtenez les métadonnées du fichier. |
createSignedUrl(bucketId: string, path: string, expiresInSeconds?: number, options?: { transform?: ImageTransform; download?: boolean | string; authToken?: string; }): Promise<AuraResponse<{ url: string; signedUrl: string; expires_in: number; }>> | Générez une URL de téléchargement signée (temporaire). |
createSignedUrls(bucketId: string, paths: string[], expiresInSeconds?: number, options?: { transform?: ImageTransform; download?: boolean | string; authToken?: string; }): Promise<AuraResponse<Array<{ path: string; url: string; signedUrl: string; expires_in: number; } | { path: string; error: AuraError; }>>> | Génère plusieurs URL signées en une seule passe (batch). |
createSignedUploadUrl(bucketId: string, path: string, expiresInSeconds?: number, options?: { upsert?: boolean; authToken?: string; }): Promise<AuraResponse<{ url: string; signedUrl: string; expires_in: number; }>> | Générez une URL de téléchargement signée (PUT présignée). |
getPublicUrl(bucketId: string, path: string, options?: { transform?: ImageTransform; download?: boolean | string; }): string | Construit une URL vers un fichier dans un compartiment. |
ClientBucketde Stockage#
Accédez au client limité à un compartiment spécifique (parité DX Supabase).
| Propriété | Descriptif |
|---|---|
readonly bucketId: string | Identifiant du bucket auquel ce client est lié : toutes ses méthodes agissent sur ce bucket. |
| Méthode | Descriptif |
|---|---|
upload(path: string, file: Blob | File | ArrayBuffer | Uint8Array, options?: { contentType?: string; upsert?: boolean; metadata?: Record<string, string>; authToken?: string; signal?: AbortSignal; onUploadProgress?: (progress: UploadProgressEvent) => void; }): Promise<AuraResponse<UploadResult>> | Téléchargez un fichier dans ce compartiment. |
uploadToSignedUrl(signedUrl: string, file: Blob | File | ArrayBuffer | Uint8Array, options?: { contentType?: string; signal?: AbortSignal; onUploadProgress?: (progress: UploadProgressEvent) => void; }): Promise<AuraResponse<UploadResult>> | Téléchargement direct vers une URL signée. |
download(path: string, options?: { transform?: ImageTransform; download?: boolean | string; }): BlobDownloadBuilder | Téléchargez un fichier à partir de ce compartiment. |
list(pathOrOptions?: string | { prefix?: string; limit?: number; offset?: number; cursor?: string; authToken?: string; }, options?: { prefix?: string; limit?: number; offset?: number; cursor?: string; authToken?: string; }): Promise<AuraResponse<FileEntry[]>> | Répertoriez les fichiers de ce compartiment. |
remove(paths: string[], options?: { permanent?: boolean; authToken?: string; }): Promise<AuraResponse<null>> | Supprime un ou plusieurs fichiers de ce compartiment. |
listTrash(options?: { prefix?: string; authToken?: string; }): Promise<AuraResponse<Array<{ key: string; size: number | null; content_type: string | null; deleted_at: string; }>>> | Répertorie les fichiers dans la corbeille de ce compartiment (suppression logicielle). |
restore(path: string, options?: { authToken?: string; }): Promise<AuraResponse<{ restored: boolean; key: string; }>> | Restaure un fichier de la corbeille. |
copy(fromPath: string, toPath: string, options?: { destinationBucket?: string; authToken?: string; }): Promise<AuraResponse<{ key: string; }>> | Copie un fichier dans ce compartiment ou dans un autre compartiment. |
move(fromPath: string, toPath: string, options?: { destinationBucket?: string; authToken?: string; }): Promise<AuraResponse<{ key: string; }>> | Déplace ou renomme un fichier dans ce compartiment ou vers un autre compartiment. |
createSignedUrl(path: string, expiresInSeconds?: number, options?: { transform?: ImageTransform; download?: boolean | string; authToken?: string; }): Promise<AuraResponse<{ url: string; signedUrl: string; expires_in: number; }>> | Crée une URL signée temporaire pour un fichier dans ce compartiment. |
getMetadata(path: string, options?: { authToken?: string; }): Promise<AuraResponse<ObjectMeta>> | Lit les métadonnées d'un fichier dans ce compartiment. |
createSignedUrls(paths: string[], expiresInSeconds?: number, options?: { transform?: ImageTransform; download?: boolean | string; authToken?: string; }): Promise<AuraResponse<Array<{ path: string; url: string; signedUrl: string; expires_in: number; } | { path: string; error: AuraError; }>>> | Crée plusieurs URL signées en une seule passe pour ce compartiment. |
createSignedUploadUrl(path: string, expiresInSeconds?: number, options?: { upsert?: boolean; authToken?: string; }): Promise<AuraResponse<{ url: string; signedUrl: string; expires_in: number; }>> | Crée une URL de téléchargement présignée (PUT direct). |
getPublicUrl(path: string, options?: { transform?: ImageTransform; download?: boolean | string; }): { data: { publicUrl: string; }; } | Renvoie l'URL publique d'un fichier dans ce bucket. |
BlobDownloadBuilder#
Téléchargement paresseux (Blob par défaut).
| Méthode | Descriptif |
|---|---|
asStream(): StreamDownloadBuilder | Passe en lecture streaming : le résultat devient un ReadableStream au lieu d'un Blob chargé en mémoire. |
then<TR1 = AuraResponse<Blob>, TR2 = never>(onfulfilled?: ((v: AuraResponse<Blob>) => TR1 | PromiseLike<TR1>) | null, onrejected?: ((e: unknown) => TR2 | PromiseLike<TR2>) | null): Promise<TR1 | TR2> | Déclenche le téléchargement (paresseux : la requête ne démarre qu'à await) ; le résultat est mémorisé. |
StreamDownloadBuilder#
Flux de variantes — res.body (ReadableStream).
| Méthode | Descriptif |
|---|---|
then<TR1 = AuraResponse<ReadableStream<Uint8Array>>, TR2 = never>(onfulfilled?: ((v: AuraResponse<ReadableStream<Uint8Array>>) => TR1 | PromiseLike<TR1>) | null, onrejected?: ((e: unknown) => TR2 | PromiseLike<TR2>) | null): Promise<TR1 | TR2> | Déclenche le téléchargement en streaming (paresseux) ; le résultat est mémorisé. |
Page générée
Cette page est générée à partir des déclarations de type et des commentaires du SDK, elle ne peut donc pas dériver du code publié. Pour des exemples concrets, lisez les guides.
@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ Signaler un problème