firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

[FR]: Set chunk size on upload task

Open cclaan opened this issue 2 years ago • 4 comments

Description

I may be missing something very obvious, but I see no way to set the upload chunk size from swift code for a 'FIRStorageUploadTask' created via FIRStorageReference putFile. e.g.

let uploadTask = remoteRef.putFile(from: fileURL, metadata: metadata)
  1. Use case: allow custom chunk sizes so resumable uploads work by default
  2. Currently the chunk size seems hard coded to a large value
  3. I propose allowing custom chunk sizes

In FIRStorageUploadTask.m the chunk size seems to be set from the constant kGTMSessionUploadFetcherStandardChunkSize which is set to LLONG_MAX;

    GTMSessionUploadFetcher *uploadFetcher =
        [GTMSessionUploadFetcher uploadFetcherWithRequest:request
                                           uploadMIMEType:strongSelf->_uploadMetadata.contentType
                                                chunkSize:kGTMSessionUploadFetcherStandardChunkSize
                                           fetcherService:self.fetcherService];

Perhaps there is a way to modify this somewhere, but I can't find any documentation on it.

Thanks for any support.

API Proposal

let uploadTask = remoteRef.putFile(from: fileURL, metadata: metadata, chunkSize: myChunkSize )

Firebase Product(s)

Storage

cclaan avatar Aug 25 '22 09:08 cclaan

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Aug 25 '22 09:08 google-oss-bot

@cclaan Thank for the feature request. You're correct that there's currently no way to change chunkSize from LLONG_MAX

We've begun work on a Swift-only V2 API for Storage in #10161. chunkSize could work well as a default argument in the new API.

paulb777 avatar Sep 16 '22 22:09 paulb777

@cclaan Would you provide more description about the value of being able to set the chunkSize. Why do you want to be able to manage the upload in smaller chunks?

paulb777 avatar Dec 16 '22 19:12 paulb777

My use case is uploading ~20mb files from a phone with potentially poor network connection. Using smaller chunks is required so that the upload does not restart from scratch every time the network drops. ( Previously chunkSize was LLONG_MAX )

cclaan avatar Dec 17 '22 15:12 cclaan