amazon s3 - Uploading a video to S3 with swift The operation couldn’t be completed. (Cocoa error 260.)" -
i trying upload video file amazon s3 error 260:
error in uploading video: error domain=nscocoaerrordomain code=260 "the operation couldn’t completed. (cocoa error 260.)
i read somewhere amazon not support asset library - true? , if suggest eran
func savevideotos3 () {
var uploadrequest: awss3transfermanageruploadrequest = awss3transfermanageruploadrequest() uploadrequest.bucket = "bucketname" uploadrequest.key = "keytext" //move video file application folder can read var savedvideourltobeused = nsuserdefaults.standarduserdefaults().objectforkey("thisisthevideoiwanttouse") as! string println("video saved in store: \(savedvideourltobeused)") var url: nsurl = nsurl(fileurlwithpath: savedvideourltobeused)! uploadrequest.body = url //uploadrequest.body = nsurl(fileurlwithpath: "file:///\(url)") println("url: \(url)") let transfermanager: awss3transfermanager = awss3transfermanager.defaults3transfermanager() transfermanager.upload(uploadrequest).continuewithexecutor(awsexecutor.mainthreadexecutor(), withblock: { (awstask) -> anyobject! in //handle errors if awstask.error != nil { println("error in uploading video: \(awstask.error)") if awstask.error.code == 1001 { self.savevideotos3() } // retrive information important later downloading } else { println("video upload successful..") var uploadresult: anyobject! = awstask.result println("upload result: \(uploadresult)") //delete file application folder } return nil }) }
cocoa error 260 nsfilereadnosuchfileerror
, meaning path specified not valid (file not is), has nothing s3 itself. there 3 things why happening come mind:
- you did not use
.synchronize()
when saving key user settings - your file url contains invalid characters
- you did not write file filesystem properly
ios8 breaking change
also please note of ios8, due changes how application work assigned sandboxes, can't save absolute url file because next time open application, different.
beginning in ios 8, documents , library directories no longer siblings of application's bundle.
i using 2 quick convenience functions wrote file cache directory:
func cachepathwithfilename(filename : string) -> string { let cachedirectorypath = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true)[0] as! string return cachedirectorypath.stringbyappendingpathcomponent(filename) }
and documents directory:
func documentspathwithfilename(filename : string) -> string { let documentsdirectorypath = nssearchpathfordirectoriesindomains(.cachesdirectory, .userdomainmask, true)[0] as! string return documentsdirectorypath.stringbyappendingpathcomponent(filename) }
hopefully of tips help!
Comments
Post a Comment