uploadFile method

Future<AGCStorageUploadTask> uploadFile(
  1. File file, {
  2. AGCStorageSettableMetadata? metadata,
  3. int offset = 0,
})

Uploads file to the cloud. You must set sha256 value to metadata for resumable uploads.

  • file: File size cannot exceed 50 GB.

Implementation

Future<AGCStorageUploadTask> uploadFile(
  File file, {
  AGCStorageSettableMetadata? metadata,
  int offset = 0,
}) async {
  try {
    final String? taskId = await _methodChannel.invokeMethod<String?>(
      'AGCStorageReference#uploadFile',
      <String, dynamic>{
        'bucket': storage.bucket,
        'policyIndex': storage.policy?.index,
        'objectPath': path,
        'filePath': file.path,
        'metadata': metadata?._toMap(),
        'offset': offset,
      },
    );
    return AGCStorageUploadTask._(taskId!, this);
  } catch (e) {
    throw AGCStorageException._from(e);
  }
}