We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Christian T.16
10 years agoNew member | Level 1
parsing upload session finish error
Can you provide an example of how to parse an upload session finish error. Here's what I have but none of these cases are triggered. I do get Error but no further details. Thanks.
...
Greg-DB
Dropbox Community Moderator
10 years agoWhat output do you get? Some errors are themselves unions, so be sure to break those out if you need.
For example, here's a sample breaking out every possible error case (with the latest version of SwiftyDropbox, v3.0.0):
// we're ready to finish the upload and commit the file
client.files.uploadSessionFinish(cursor: Files.UploadSessionCursor(sessionId: result.sessionId, offset: fileLength),
commit: Files.CommitInfo(path: "/test_swift_upload_session.txt"),
// no additional data to add at this point in this case
body:NSData()).response { response, error in
if let result = response {
print("Result: \(result)")
} else if let callError = error {
switch callError as CallError {
case .RouteError(let boxed, let requestId):
print("RouteError[\(requestId)]:")
switch boxed.unboxed as Files.UploadSessionFinishError {
case .Path(let fileLookupError):
print("Path: ")
switch fileLookupError {
case .MalformedPath(let malformedPathError):
print("MalformedPath: \(malformedPathError)")
case .Conflict(let writeConflictError):
print("Conflict:")
switch writeConflictError {
case .File:
print("File")
case .FileAncestor:
print("FileAncestor")
case .Folder:
print("Folder")
case .Other:
print("Other")
}
case .DisallowedName:
print("DisallowedName")
case .InsufficientSpace:
print("InsufficientSpace")
case .NoWritePermission:
print("NoWritePermission")
case .Other:
print("Other")
}
case .LookupFailed(let uploadSessionLookupError):
print("LookupFailed:")
switch uploadSessionLookupError {
case .Closed:
print("Closed")
case .IncorrectOffset(let uploadSessionOffsetError):
print("IncorrectOffset: \(uploadSessionOffsetError)")
case .NotFound:
print("NotFound")
case .Other:
print("Other")
}
case .Other:
print("Other")
}
case .BadInputError(let message, let requestId):
print("BadInputError[\(requestId)]: \(message)")
case .HTTPError(let code, let message, let requestId):
print("HTTPError[\(requestId)]: \(code): \(message)")
case .InternalServerError(let code, let message, let requestId):
print("InternalServerError[\(requestId)]: \(code): \(message)")
case .OSError(let err):
print("OSError: \(err)")
case .RateLimitError:
print("RateLimitError")
}
}
}
Apologies for the poor formatting on the forum!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!