Start a new topic

How download file by Name?

I download image from kinvey server, using this code by ID:

this.file = new File(folder, idImage);

this.fileMetaData = new FileMetaData(idImage);

this.fileOutputStream = new FileOutputStream(file);

client.file().download(fileMetaData, fileOutputStream, new DownloaderProgressListener()

{

@Override

public void onSuccess(Void arg0)

{ //Set File to ImageView }

@Override

public void onFailure(Throwable t)

{ //FAIL }

@Override

public void progressChanged(MediaHttpDownloader arg0) throws IOException { }

});

How download images from Kinvey Server by File_Name?
1 Comment

Does every file have a unique file name? By default the library the uses _id for lookups because each one is guaranteed to be unique.



Check out the javadocs for the File API, there is a download method that takes a query-- can you try this?



http://devcenter.kinvey.com/android/reference/api/reference/com/kinvey/android/AsyncFile.html#download(com.kinvey.java.Query, java.io.OutputStream, com.kinvey.java.core.DownloaderProgressListener)



If you use the query to match a filename it should do it for ya-- although you might need a very specific query because this method will only download the first result returned.
Login or Signup to post a comment