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)
The file url looks like this:
file:///var/mobile/Containers/Data/Application/861A23DF-EF32-4458-AA9D-C3F94BB1A4F8/Documents/Session_AmOH6ME627mVbOeIdVIT.zip
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"])
I don't understand the error "Message too long" ?
Any help would be greatly appreciated thank you
- I have tried to force the upload to happen on the Main thread
- I have tried to move or copy the zip somewhere else
- I have tried putData
What I see has worked is trying again and again. Eventually after X tries it works. Why does it work sometimes but not all the time ?