-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Significant delay before uploading large files with multipart #3864
Comments
Alamofire's multipart form handling has a long history. Specifically, it was designed when the library kinda sorta supported background The true answer is to allow for streaming uploads while either guaranteeing the upload can't happen in the background, or creating some sort of mechanism to allow it to smoothly transition to the background while in progress. This is a huge unsolved area in Alamofire 5 due to the time investment required to fully understand the limits of background I'm going to mark this as a feature request in case someone wants to investigate, but I don't know when I'll have the time to work on it myself. |
I am assuming that by 'background' you mean iOS background restrictions. I am new to iOS so I don't know much about that space. However, I see on the Github repo that Alamofire supports a bunch of different OSes and platforms. Because of this it doesn't make sense to me to prioritize this background/foreground feature from a scoping perspective. I believe it would make more sense to break this into smaller pieces of work such as:
Overall there seems like a huge gap in the iOS space for doing multipart form requests with streaming. I talked to a few iOS dev friend of mine with years of experience to see what they use for the job and they either implement their own or use Alamofire (with the limitation mentioned above). |
Background handling isn't really optional for large uploads on iOS. No user will sit with your app open while a 600MB file uploads. They will immediately switch to doing something else, or close their phone entirely. Really you'd want to start the upload using a background-configured And while Alamofire technically builds for the other platforms Swift supports, |
What did you do?
Upload big files within a multipart form request. Here is the code I am using:
What did you expect to happen?
The upload to start instantly.
What happened instead?
There is a significant delay before the calling of
AF.upload()
and a 'tick' to the upload progress. I suspect this is due to saving the files to disk before uploading (after reading theencodingMemoryThreshold
documentation).I tried uploading a ~600mb file to my server and it takes 3 seconds for the upload to start.
PS: I find it weird that the files needs to be saved to disk before uploading, as the files i am trying to upload are already stored on disk (uploading files from file extension). is there a way to upload the files directly from disk that I am not aware of?
Alamofire Environment
Alamofire Version: 5.9.1
Dependency Manager:
Xcode Version: 15.3
Swift Version:
Platform(s) Running Alamofire: iPhone 15 Simulator, iPhone 12 Pro Max (real device)
macOS Version Running Xcode: MBP M3 Max
The text was updated successfully, but these errors were encountered: