Backendless Support
 
Answered

IOS image UPLOAD (non blocking method)

Hi,

Can you tell me a complete example of an IOS image UPLOAD in a non blocking method?.

I have tried unsuccessfully to use the one in the SDK:

func backendless.file.upload(path: String, content: Data, overwrite: Bool, response: (BackendlessFile -> Void), error: (Fault -> Void)) -> Void

Greetings and many thanks in advance,

Leave a Comment

Comments (2)

photo
1

Hello Joan,

Please check this code:

  1. func uploadImage() {
  2. let filePathName = "MyUplaodedImages/myUploadedImage.png"
  3. let image = UIImage(named: "myImage.png")
  4. let imageData = UIImagePNGRepresentation(image!)
  5. Backendless.sharedInstance().fileService.uploadFile(filePathName, content: imageData, overwriteIfExist: true, response: { uploadedImage in
  6. print("Image has been uplaoded: \(uploadedImage?.fileURL ?? "...")")
  7. }, error: { fault in
  8. print("Error: \(fault?.message ?? "uplaod failed")")
  9. })
  10. }

Result attached.

Regards, Olga

photo
1

Correctly tested !!