updateFile method

Future<File> updateFile({
  1. required String bucketId,
  2. required String fileId,
  3. String? name,
  4. List<String>? permissions,
})

Update file

Update a file by its unique ID. Only users with write permissions have access to update this resource.

Implementation

Future<models.File> updateFile(
    {required String bucketId,
    required String fileId,
    String? name,
    List<String>? permissions}) async {
  final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'
      .replaceAll('{bucketId}', bucketId)
      .replaceAll('{fileId}', fileId);

  final Map<String, dynamic> apiParams = {
    'name': name,
    'permissions': permissions,
  };

  final Map<String, String> apiHeaders = {
    'content-type': 'application/json',
  };

  final res = await client.call(HttpMethod.put,
      path: apiPath, params: apiParams, headers: apiHeaders);

  return models.File.fromMap(res.data);
}