ResumableUploadOptions constructor

ResumableUploadOptions(
  1. {int numberOfAttempts = 3,
  2. int chunkSize = 1024 * 1024,
  3. Duration? backoffFunction(
    1. int
    ) = exponentialBackoff}
)

Implementation

ResumableUploadOptions({
  this.numberOfAttempts = 3,
  this.chunkSize = 1024 * 1024,
  this.backoffFunction = exponentialBackoff,
}) {
  // See e.g. here:
  // https://developers.google.com/maps-engine/documentation/resumable-upload
  //
  // Chunk size restriction:
  // There are some chunk size restrictions based on the size of the file you
  // are uploading. Files larger than 256 KB (256 x 1024 bytes) must have
  // chunk sizes that are multiples of 256 KB. For files smaller than 256 KB,
  // there are no restrictions. In either case, the final chunk has no
  // limitations; you can simply transfer the remaining bytes. If you use
  // chunking, it is important to keep the chunk size as large as possible
  // to keep the upload efficient.
  //
  if (numberOfAttempts < 1) {
    throw ArgumentError.value(
      numberOfAttempts,
      'numberOfAttempts',
      'Must be >= 1.',
    );
  }

  const minChinkSize = 256 * 1024;

  if (chunkSize < 1 || (chunkSize % minChinkSize) != 0) {
    throw ArgumentError.value(
      chunkSize,
      'chunkSize',
      'Must be > 0 and a multiple of $minChinkSize.',
    );
  }
}