Firebase Storage Upload ErrorCode 40
Description
I am attempting to upload a zip file to Firebase storage. The zip file is located in the documents directory for my app.
I create the reference and use putFile to start the upload
`let storageReference = ORBFirestore.getStorage() .reference(withPath: "users/") .child("(userId)/(sensorZippedFolder.lastPathComponent)")
let uploadTask = storageReference.putFile(from: sensorZippedFolder, metadata: self.remoteStorageMetaData)`
Observing the progress I can see that it reaches 100% and then throws an error.
The error I receive looks like this:
Failed to upload zip to remote storage: FirebaseStorage.StorageError.unknown(message: "Unexpected 40 code from backend", serverError: ["NSErrorPeerAddressKey": <1c1e01bb 00000000 2a001450 400b0c02 00000000 0000005f 00000000>, "_NSURLErrorRelatedURLSessionTaskErrorKey": <__NSArrayI 0x10fe5e020>( BackgroundUploadTask .<1>, LocalUploadTask .<1> ) , "_kCFStreamErrorCodeKey": 40, "_NSURLErrorFailingURLSessionTaskErrorKey": BackgroundUploadTask .<1>, "_kCFStreamErrorDomainKey": 1, "ResponseErrorDomain": "NSPOSIXErrorDomain", "ResponseErrorCode": 40, "bucket": "orb-storage-01-dev-us", "NSUnderlyingError": Error Domain=NSPOSIXErrorDomain Code=40 "Message too long" UserInfo={_NSURLErrorFailingURLSessionTaskErrorKey=BackgroundUploadTask .<1>, _kCFStreamErrorDomainKey=1, NSErrorPeerAddressKey={length = 28, bytes = 0x1c1e01bb 00000000 2a001450 400b0c02 ... 0000005f 00000000 }, _kCFStreamErrorCodeKey=40, _NSURLErrorRelatedURLSessionTaskErrorKey=( "BackgroundUploadTask .<1>", "LocalUploadTask .<1>" )}, "object": "users/IeQFdqCmT9Xncfo2zNf2iugd7Yp2/Session_AmOH6ME627mVbOeIdVIT.zip"])
Reproducing the issue
I can reproduce it easily but adding a folder to my documents directory then wait a few seconds and zip it and try and upload it
Firebase SDK Version
11.4
Xcode Version
16.3
Installation Method
Swift Package Manager
Firebase Product(s)
Storage
Targeted Platforms
iOS
Relevant Log Output
FirebaseStorage.StorageError.unknown(message: "Unexpected 40 code from backend", serverError: ["object": "users/IeQFdqCmT9Xncfo2zNf2iugd7Yp2/Session_J4krK1y74Xt27UQWnqJu.zip", "_kCFStreamErrorDomainKey": 1, "bucket": "orb-storage-01-dev-us", "NSUnderlyingError": Error Domain=NSPOSIXErrorDomain Code=40 "Message too long" UserInfo={_NSURLErrorFailingURLSessionTaskErrorKey=BackgroundUploadTask <4A643D86-8044-463E-A3AE-CCA4EECD35F1>.<1>, _kCFStreamErrorDomainKey=1, NSErrorPeerAddressKey={length = 28, bytes = 0x1c1e01bb 00000000 2a001450 400b0c03 ... 0000005f 00000000 }, _kCFStreamErrorCodeKey=40, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"BackgroundUploadTask <4A643D86-8044-463E-A3AE-CCA4EECD35F1>.<1>",
"LocalUploadTask <4A643D86-8044-463E-A3AE-CCA4EECD35F1>.<1>"
)}, "ResponseErrorDomain": "NSPOSIXErrorDomain", "NSErrorPeerAddressKey": <1c1e01bb 00000000 2a001450 400b0c03 00000000 0000005f 00000000>, "_NSURLErrorRelatedURLSessionTaskErrorKey": <__NSArrayI 0x104706e60>(
BackgroundUploadTask <4A643D86-8044-463E-A3AE-CCA4EECD35F1>.<1>,
LocalUploadTask <4A643D86-8044-463E-A3AE-CCA4EECD35F1>.<1>
)
, "_NSURLErrorFailingURLSessionTaskErrorKey": BackgroundUploadTask <4A643D86-8044-463E-A3AE-CCA4EECD35F1>.<1>, "_kCFStreamErrorCodeKey": 40, "ResponseErrorCode": 40])
If using Swift Package Manager, the project's Package.resolved
Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Hi @MalcolmnDEV, may I know if you're using simulator? Per checking the related issues, it seems to be an intermittent issue with iOS simulator.
@rizafran it was using an iPhone SE 3rd Gen iOS 18.5
Just to confirm, is it a physical device or a simulator?
@rizafran this was a physical device
@rizafran Good afternoon, any update here ?
Sorry for the late revert, @MalcolmnDEV. Is it possible for you to share an MCVE that reproduces the issue?