As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Also try "file.uploadURL?" instead of "file.uploadURL!". Avoid use of "!". Declare variable optional (?), not implicitly unwrapped optionals
Thanks,
Pranav
Kinvey
Hi Pranav,
Thanks for your response.
1. Yes I am using iOS SDK 3.3.8
2. Yes, the example provided in the link is the exact example I am using, please see my code below.
@objc func uploadUserImage(image: UIImage, imageId: String, notiName: String, name: String){
let uploadFileStore = FileStore.getInstance()
let file = File()
file.publicAccessible = true
file.fileId = imageId
file.fileName = name
uploadFileStore.upload(file, image: image){file, error in
if error != nil{
//Failed
NotificationCenter.default.post(name: Notification.Name(rawValue: notiName), object: nil, userInfo: ["profilePicConf": "notSaved"])
}
else{
//Success
NotificationCenter.default.post(name: Notification.Name(rawValue: notiName), object: nil, userInfo: ["profilePicConf": "Saved"])
}
}
}
3. The error is in the Kinvey file called FileStore.swift, which I cannot edit. I have attached a photo of the error file with the error showing. This error occurs when I call my uploadUserImage method shown above.
Hi Pranav,
I have replaced my code with the code from your previous comment. The code is now as below. The error is still the same. Please help.
@objc func uploadUserImage(imagePath: NSString, imageId: String, notiName: String, name: String){
let uploadFileStore = FileStore.getInstance()
let file = File()
file.publicAccessible = true
file.fileId = imageId
file.fileName = name
var image = UIImage(contentsOfFile: imagePath as String)
let path = imagePath as String
uploadFileStore.upload(file, path: path){file, error in
if error != nil{
}
else{
print("Success")
}
}
Thanks.
Divey
func file_upload() { let fileStore = FileStore.getInstance() let file = File() file.publicAccessible = true file.fileName = "welcome.mp4" let path = "/Users/pranav/Desktop/Work/mytestprojects/Kinvey3nopods/Kinvey3nopods/welcome.mp4" //String path for the file that will be upload //Uploads a file using a file string path fileStore.upload(file, path: path) { file, error in if let file = file { //success print("File upload succeeded") print("File: \(file)") } else { //fail print("File upload failed: \(error)") } } }
Thanks,
Pranav
Kinvey
Your code does not work for me. One thing I did notice is your file path says Kinvey No Pod. I downloaded Kinvey using Cocoapods, would that cause any issues?
Thanks.
Divey
Hello Divey,
We are happy to report that the Engineering team has identified and fixed this problem. They expect to complete testing and have an updated version of the iOS SDK available for download on or before the close of business Eastern Time, Friday, March 10, 2017 (this week).
We hope that this helps. Someone will confirm with you when the download is available. Please let us know if you have any questions.
Regards,
Billy Gee
MLIBZ-1718
Hello Divey,
We are pleased to announce that a new version of the Kinvey iOS SDK v3.3.9 is available for download at the following URL.
http://devcenter.kinvey.com/ios/downloads
This release fixes the problem described in this ticket regarding upload problem that you encountered. At your earliest convenience, please download the new update and test it.
Since this problem was posted in two places, I am going close the support ticket that is associated with this problem. That would be ticket number https://support.kinvey.com/helpdesk/tickets/3457.
Please let us know if you have any questions.
Regards,
Hi Billy,
Thanks for your quick help with this, I really appreciate it. I am now able to upload images, but unable to mark the acl as global. There has been a ticket raised on the forum 4 days ago "Swift set ACL globalRead = true for files", so I am surprised that this issue has not been fixed in the recent release.
At this stage the upload function is useless to me as I need the ability for public readable photos.
Please help me with this.
Thanks.
Divey
Divey Punj
Hi, I am trying to upload an image to FileStore but keep getting the following error:
"fatal error: unexpectedly found nil while unwrapping an Optional value"
When I started to debug, it seems like the code is failing inside a Kinvey function as shown below:
if let _ = file.fileId {
var request = URLRequest(url: file.uploadURL!)
It is failing at the var request line. The Kinvey documents do not tell me to specify an upload URL, so I am not sure if this is supposed to be assigned automatically or not.
Note: The upload function was working, before I updated to the latest Kinvey SDK.
Any help with this will be appreciated.
Thanks,
Divey