from.upload()"

将一个文件上传到一个现有的bucket.

final avatarFile = File('path/to/file');
final res = await supabase
  .storage
  .from('avatars')
  .upload('public/avatar1.png', avatarFile, fileOptions: FileOptions(
    cacheControl: '3600',
    upsert: false
  ));

Parameters

  • path required string

    相对文件路径。应该是`folder/subfolder/filename.png`的格式。在尝试上传之前,该bucket必须已经存在。
  • fileBody required ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | ReadableStream | ReadableStream | URLSearchParams | string

    要存储在bucket中的文件的主体。
  • fileOptions optional FileOptions

    HTTP headers. `cacheControl`: string, the `Cache-Control: max-age=` seconds value. `contentType`: string, the `Content-Type` header value. Should be specified if using a `fileBody` that is neither `Blob` nor `File` nor `FormData`, otherwise will default to `text/plain;charset=UTF-8`. `upsert`: boolean, whether to perform an upsert.

Notes

  • 所需的策略权限:
    • buckets 权限: none
    • objects 权限: insert

Examples

上传文科

final avatarFile = File('path/to/file');
final res = await supabase
  .storage
  .from('avatars')
  .upload('public/avatar1.png', avatarFile, fileOptions: FileOptions(
    cacheControl: '3600',
    upsert: false
  ));

results matching ""

    No results matching ""