0

I'm trying to use the example where a file is uploaded using NSFileHandle. I get the following compile errors:

I get this 2 times:

Cannot invoke 'uploadSessionStart' with an argument list of type '(input: NSData?)'

I get the errors once in uploadFirstChunk() and once in uploadNextChunk(), both times in this statement:

var data : NSData? = nil
...
data = fileHandle!.readData(ofLength: chunkSize) as NSData?
...
dbClient.files.uploadSessionStart(input: data)<==

I also get this error in uploadNextChunk():

Type of expression is ambiguous without more context

This is the statement where it occurs:

let destPath = "/MDG/test/Test1.mp4"
...
dbClient.files.uploadSessionFinish(
                cursor: Files.UploadSessionCursor(sessionId: self.sessionId, offset: UInt64(offset)),
                commit: Files.CommitInfo(path: destPath),<==
                input: data!)
MickeDG
  • 404
  • 5
  • 18
  • Are you referring to [this example](https://stackoverflow.com/documentation/dropbox-api/409/uploading-a-file/20600/uploading-a-file-from-nsfilehandle-using-upload-sessions-with-every-error-case-h#t=201611072151202556814)? That's probably a bit out of date, and should be updated for the latest version of the SDK. – Greg Nov 07 '16 at 23:38
  • 1
    In that case, to get your code working, make sure you're using the right method definitions. E.g., [`uploadSessionStart`](https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:FC13SwiftyDropbox11FilesRoutes18uploadSessionStartFT5closeSb5inputV10Foundation4Data_GCS_13UploadRequestCCS_5Files34UploadSessionStartResultSerializerCS_14VoidSerializer_) takes two parameters now. The autocomplete in Xcode should help. – Greg Nov 07 '16 at 23:39
  • Thanks Greg - finally got it working! Another question - if I want the upload to continue uninterrupted even if the user leaves the view controller, I assume that I need to start the upload in an asynchronous thread? Now I get "Error Domain=NSURLErrorDomain Code=-999 \"cancelled\"...." if I leave during an upload. – MickeDG Nov 10 '16 at 14:56
  • 1
    There are some customization options here: https://github.com/dropbox/SwiftyDropbox#customizing-network-calls – Greg Nov 10 '16 at 19:11

0 Answers0