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.
i cannot download the array of images to the app i n swift , what is the best way to download the number of image to sorted into tableview from the Files in the backend .
Best Answer
P
Pranav J
said
almost 7 years ago
Rami,
Here is a screenshot from my test application where you can see 13 files downloaded (since I had uploaded the same file multiple times). You can see the printed input array of names ( 3 names provided as input) and the “Downloaded 13 images” log.
As I compare your function and my function, here are a couple of things I can think of :
1. Can you confirm that your images have no extension (when you view them in the Kinvey Console)?
2. Your “DownloadImages” function is using KCSFileStore.downloadDataByQuery() to download. Can you instead switch to using KCSFileStore.downloadFileByQuery() and let me know your results?
3. If the above change still doesn’t work for you, can you hardcode your input array just to contain 1 file in it (“ramyal”)( one of the files that does not get downloaded) and see if that is downloaded properly?
this the code i am using as per with the screenshot the the value are saved in array for the looking value with the files but the download result is only one image ? how i can download the images that i need in array .
r
rami mokhtar
said
almost 7 years ago
this the new code i am using but the issue is only downloading the last element of the array
// the below code for showing and reload the cell on the table view
self.changer = true
self.tableView.reloadData()
}
}
}
P
Pranav J
said
almost 7 years ago
Rami,
Can you try with .KCSIn? Here is a sample code snippet to try (in listofNames replace your filenames)..
var listOfNames = ["otexture11.png", "IMG_1493.JPG","mtexture11.png"]
print(listOfNames)
let pngQuery = KCSQuery(onField: KCSFileFileName, usingConditional: .KCSIn, forValue: listOfNames as! NSObject)
KCSFileStore.downloadFileByQuery(
pngQuery,
completionBlock: { (downloadedResources: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
NSLog("Downloaded %i images.", downloadedResources.count)
} else {
NSLog("Got an error: %@", error)
}
},
progressBlock: nil
)
Let me know if it works for you.
Thanks,
Pranav
Kinvey Support
r
rami mokhtar
said
almost 7 years ago
Pranav,
thank your for reply , the issue still the same the function only download the active user this what appear to me .
what i need is to download all the images for the specific users i give to the function .
Thanks ,
P
Pranav J
said
almost 7 years ago
Rami,
I have tried the above code and it does download all the images that are specified in the “listofnames" array. If you specify some of your image names in the “listofnames” what are your results? If you could let me know with some of your examples that would help.
Thanks, Pranav Kinvey Support
r
rami mokhtar
said
almost 7 years ago
i am using this code to inquiry the names of the Images
func NumberOfCells(Name0FRest : String) {
let collection = KCSCollection(fromString: "Comments", ofClass: NSDictionary.self)
Here is a screenshot from my test application where you can see 13 files downloaded (since I had uploaded the same file multiple times). You can see the printed input array of names ( 3 names provided as input) and the “Downloaded 13 images” log.
As I compare your function and my function, here are a couple of things I can think of :
1. Can you confirm that your images have no extension (when you view them in the Kinvey Console)?
2. Your “DownloadImages” function is using KCSFileStore.downloadDataByQuery() to download. Can you instead switch to using KCSFileStore.downloadFileByQuery() and let me know your results?
3. If the above change still doesn’t work for you, can you hardcode your input array just to contain 1 file in it (“ramyal”)( one of the files that does not get downloaded) and see if that is downloaded properly?
Let me know your results.
Thanks,
Pranav
Kinvey Support
r
rami mokhtar
said
almost 7 years ago
Pranav,
Thank you fro your reply .
1- yes my images have no ext. but when i request to download the image for the active user its working fine .
2- yes i have try this also KCSFileStore.downloadFileByQuery() the same
i have two method of download i have try .
first one i download the images regarding to the filename_ which the same of the user Name i have in the backend file with no ext and its work if i call the active user image only other images give me 0 .
second try the create Column name "Img_Id" having attribute by assigning the user ID to this column
the problem in both method that the code download only the active user image or if i use the option .KCSAll its download the active user with the image in back end file all .
note :- the image in the files has been uploaded from the User in app .
r
rami mokhtar
said
almost 7 years ago
this the second method which is i am using specific column have uploaded attribute by user
as the SC the print result give me the correct IDs in the Files backend but the download is only one and the one downloaded is the only active user image .
r
rami mokhtar
said
almost 7 years ago
i think the issue is on the Files on the backend , check this SC , i have add the ext. as the drag drop image i ask you before and its work with it but with the username is not working still the same could you check the SC i think the issue in _acl how can i fix it .
agin its only download the Active user Image .
r
rami mokhtar
said
almost 7 years ago
Pranav,
thanks for you kind support , i have fix the issue it was with the _acl in the backend not with the download function
rami mokhtar
i cannot download the array of images to the app i n swift , what is the best way to download the number of image to sorted into tableview from the Files in the backend .
Here is a screenshot from my test application where you can see 13 files downloaded (since I had uploaded the same file multiple times).
You can see the printed input array of names ( 3 names provided as input) and the “Downloaded 13 images” log.
As I compare your function and my function, here are a couple of things I can think of :
1. Can you confirm that your images have no extension (when you view them in the Kinvey Console)?
2. Your “DownloadImages” function is using KCSFileStore.downloadDataByQuery() to download. Can you instead switch to using KCSFileStore.downloadFileByQuery() and let me know your results?
3. If the above change still doesn’t work for you, can you hardcode your input array just to contain 1 file in it (“ramyal”)( one of the files that does not get downloaded) and see if that is downloaded properly?
Let me know your results.
Thanks,
Pranav
Kinvey Support
- Oldest First
- Popular
- Newest First
Sorted by Oldest Firstrami mokhtar
this the code i am using as per with the screenshot the the value are saved in array for the looking value with the files but the download result is only one image ? how i can download the images that i need in array .
rami mokhtar
this the new code i am using but the issue is only downloading the last element of the array
---------------------------------------------------------------------------
func DownloadImages(ImagesId : [String]) -> Void {
var fileUrl = NSURL()
//ImagesId its the array of the name i requested
for Names in ImagesId {
KCSFileStore.downloadFileByName(Names,completionBlock: { (downloadedResources: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
for Counting in ImagesId {
print(Counting)// counting the elements in the array to do the below function
// till here every things is OK but when download image its only download the last element ??
if let Pic = downloadedResources as? [KCSFile]{
for picsID in Pic{
fileUrl = picsID.localURL
self.image.append(UIImage(contentsOfFile: fileUrl.path!)!)
// the below code for showing and reload the cell on the table view
self.changer = true
self.tableView.reloadData()
}
}
}
Pranav J
Rami,
Can you try with .KCSIn? Here is a sample code snippet to try (in listofNames replace your filenames)..
Let me know if it works for you.
Thanks,
Pranav
Kinvey Support
rami mokhtar
Pranav,
thank your for reply , the issue still the same the function only download the active user this what appear to me .
what i need is to download all the images for the specific users i give to the function .
Thanks ,
Pranav J
I have tried the above code and it does download all the images that are specified in the “listofnames" array.
If you specify some of your image names in the “listofnames” what are your results?
If you could let me know with some of your examples that would help.
Thanks,
Pranav
Kinvey Support
rami mokhtar
i am using this code to inquiry the names of the Images
func NumberOfCells(Name0FRest : String) {
let collection = KCSCollection(fromString: "Comments", ofClass: NSDictionary.self)
DownCells.storeComments = KCSCachedStore(collection: collection , options: [ KCSStoreKeyCachePolicy : KCSCachePolicy.LocalFirst.rawValue ])
let query = KCSQuery()
DownCells.storeComments.queryWithQuery(
query,
withCompletionBlock: { (objectsOrNil: [AnyObject]!, errorOrNil: NSError!) -> Void in
if errorOrNil == nil {
//extract just the Value field from the entities
for d in objectsOrNil as! [NSDictionary] {
let userName = d.valueForKey("User_Name") as? String
let valueValue = d.valueForKey("Rest_Name") as? String
let CommentsValue = d.valueForKey("Comments") as? String
let user_img = d.valueForKey("Img_Id") as? String
// check if value nil or not to avoid the download error
if valueValue != nil {
if valueValue == Name0FRest {
self.valueValue_.append(valueValue!)
if userName != nil {
if valueValue == Name0FRest {
// fill the array of Users Name
self.userName_.append(userName!)
// fill the array of Comments
self.CommentsValue_.append(CommentsValue!)
// fill the array of Images Name
self.user_img_Id.append(user_img!)
}
}
}
}
}
// insert the names of the user comments to doownload ther images
self.refreshControl.endRefreshing()
self.tableView.reloadData()
// here i add the array of the names that i download it to the function to download the images by name .
self.DownloadImages(self.user_img_Id)
----------
then i use the this code to download the images with the extracted value.
and the result is as per below , the names are correct but the issue is the code only download the last name
and if i use the option .KCSAll
this the result
ramyal
ramyal
Ram
2016-06-21 11:57:03.806 FoodRate2[818:250483] Got an error: Error Domain=KCSResourceErrorDomain Code=60011 "Download already in progress." UserInfo={_id=f4acd09f-3227-4aa9-9c9c-79db79e30276, NSLocalizedDescription=Download already in progress.}
2016-06-21 11:57:03.912 FoodRate2[818:250483] Got an error: Error Domain=KCSResourceErrorDomain Code=60011 "Download already in progress." UserInfo={_id=f4acd09f-3227-4aa9-9c9c-79db79e30276, NSLocalizedDescription=Download already in progress.}
2
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
this the second method i have test that i assign the array to be downloaded
func DownloadImages(ImagesId : [String]) -> Void {
// var fileUrl = NSURL()
// Sequence the array name by name to requested from the Backend
// print(Names)
let query = KCSQuery(onField: KCSFileFileName, usingConditional: .KCSIn, forValue: ImagesId as NSObject)
print(ImagesId)
KCSFileStore.downloadDataByQuery(query,completionBlock: { (downloadedResources: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
print(downloadedResources.count)
} else {
NSLog("Got an error: %@", error)
}
},progressBlock: nil)
}
and this the result
["ramyal", "ramyal", "Ram"]
Ram
1
Pranav J
Here is a screenshot from my test application where you can see 13 files downloaded (since I had uploaded the same file multiple times).
You can see the printed input array of names ( 3 names provided as input) and the “Downloaded 13 images” log.
As I compare your function and my function, here are a couple of things I can think of :
1. Can you confirm that your images have no extension (when you view them in the Kinvey Console)?
2. Your “DownloadImages” function is using KCSFileStore.downloadDataByQuery() to download. Can you instead switch to using KCSFileStore.downloadFileByQuery() and let me know your results?
3. If the above change still doesn’t work for you, can you hardcode your input array just to contain 1 file in it (“ramyal”)( one of the files that does not get downloaded) and see if that is downloaded properly?
Let me know your results.
Thanks,
Pranav
Kinvey Support
rami mokhtar
Pranav,
Thank you fro your reply .
1- yes my images have no ext. but when i request to download the image for the active user its working fine .
2- yes i have try this also KCSFileStore.downloadFileByQuery() the same
i have two method of download i have try .
first one i download the images regarding to the filename_ which the same of the user Name i have in the backend file with no ext and its work if i call the active user image only other images give me 0 .
second try the create Column name "Img_Id" having attribute by assigning the user ID to this column
the problem in both method that the code download only the active user image or if i use the option .KCSAll its download the active user with the image in back end file all .
note :- the image in the files has been uploaded from the User in app .
rami mokhtar
this the second method which is i am using specific column have uploaded attribute by user
as the SC the print result give me the correct IDs in the Files backend but the download is only one and the one downloaded is the only active user image .
rami mokhtar
i think the issue is on the Files on the backend , check this SC , i have add the ext. as the drag drop image i ask you before and its work with it but with the username is not working still the same could you check the SC i think the issue in _acl how can i fix it .
agin its only download the Active user Image .
rami mokhtar
Pranav,
thanks for you kind support , i have fix the issue it was with the _acl in the backend not with the download function
i use the metadata .
Now you can mark this as answered :)
let value_ = KCSMetadata()
value_.setGloballyReadable(true)
Thanks,
Pranav J
Excellent..! Glad it worked for you.
Thanks,
Pranav
Kinvey Support
-
Why do I get "Undefined symbols" errors when building with KinveyKit?
-
How do I register push tokens?
-
When using social login, to perform a log-out, do I need to log out of the social network, Kinvey, o
-
How can I assign additional properties to users?
-
Does KinveyKit support 64-bit ARM devices, such as iPhone 5s?
-
Authorization Token Invalid or Expired
-
BOOL and how it is stored in the database.
-
Offline saving throwing errors
-
Custom endpoint not able to form request object
-
Security through business logic
See all 437 topics