edge/doc/apps/server-api/blob.md

73 lines
1.5 KiB
Markdown
Raw Normal View History

2023-02-09 12:16:36 +01:00
# Module `blob`
Ce module permet de manipuler des fichiers ("blobs") au sein de votre application.
## Fonctions de rappel
Pour permettre aux utilisateurs de téléverser/télécharger des fichiers ("blobs") dans votre application, il vous faudra déclarer 2 fonctions dans votre fichier `server/main.js`.
### `onBlobUpload(ctx: Context, blobId: string, blobInfo: BlobInfo, metadata: Metadata)`
> `TODO`
#### Usage
```js
function onBlobUpload(ctx, blobId, blobInfo, metadata) {
// Autoriser le téléversement et indiquer que le fichier doit être stocké dans le bucket "my-bucket"
return { allow: true, bucket: "my-bucket" };
}
```
### `onBlobDownload(ctx: Context, bucketName: string, blobId: string)`
> `TODO`
#### Usage
```js
function onBlobDownload(ctx, bucketName, blobId) {
// Autoriser le téléchargement
return { allow: true };
}
```
## Méthodes
### `blob.listBuckets(ctx: Context): string[]`
> `TODO`
### `blob.writeBlob(ctx: Context, bucketName: string, blobId: string)`
> `TODO`
### `blob.readBlob(ctx: Context, bucketName: string, blobId: string)`
> `TODO`
### `blob.listBlobs(ctx: Context, bucketName: string): BlobInfo[]`
> `TODO`
### `blob.deleteBlob(ctx: Context, bucketName: string, blobId: string)`
> `TODO`
### `blob.deleteBucket(ctx: Context, bucketName: string)`
> `TODO`
### `blob.getBlobInfo(ctx: Context, bucketName: string, blobId: string): BlobInfo`
> `TODO`
## Objets
### `Context`
Voir la documentation de l'objet [`Context`](./context.md#Context).
### `BlobInfo`
### `Metadata`