Start a new topic

Image Downloading, BlobNotFound. This blob not found for this app backend

In an android app,I am trying to download 1 image which is stored in Kinvey backend (not uploading though). But if I try to fetch that image, it is giving , com.kinvey.java.core.KinveyJsonResponseException: BlobNotFound this exception. As I can see in my storage path of device, image is corrupted. Below is the code I've used for downloading a file,




private void checkImage(String imageId, final ImageView imageView) throws IOException {
if (imageId == null) {
return;
}
final File outputDirectory = new File(Environment.getExternalStorageDirectory() + Constants.IMAGE_DIRECTORY);
if (!outputDirectory.exists()) {
outputDirectory.mkdirs();
}
final File outputFile = new File(Environment.getExternalStorageDirectory() + Constants.IMAGE_DIRECTORY + "/" + imageId + Constants.IMAGE_EXTENSION);
Log.i("TAG", "outputFile == " + outputFile);
if (!outputFile.exists()) {
outputFile.createNewFile();
}
final FileOutputStream fos = new FileOutputStream(outputFile);
FileMetaData fileMetaDataForDownload = new FileMetaData(imageId);

App.getKinveyClient().file().download(fileMetaDataForDownload, fos, new DownloaderProgressListener() {
@Override
public void onSuccess(Void args) {
try {
fos.write(outputFile.getAbsolutePath().getBytes());
imageView.setImageBitmap(BitmapFactory.decodeFile(outputFile.getAbsolutePath()));
//Toast.makeText(getApplication(), R.string.toast_successful, Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public void onFailure(Throwable throwable) {
// Toast.makeText(getApplication(), R.string.toast_unsuccessful, Toast.LENGTH_SHORT).show();
Log.d(TAG, "throwable == "+throwable.toString());
}

@Override
public void progressChanged(MediaHttpDownloader mediaHttpDownloader) throws IOException {
//Log.d(TAG, "progressChanged");
}

}); 


It would be great if anybody could tell me cause of this. Thank you in advance.



1 Comment

Aarti,

  1. Do you see the file properly uploaded under “Files” in the Kinvey Console and its file_id? Is the file id that you are passing to the download function correct? Can you verify that?
  2. When viewing the File under "Kinvey Console=>Files”, when you click on the “Download Link” does it open the file in the browser?
  3. Can you test uploading/downloading files using Kinvey API console? Check https://devcenter.kinvey.com/rest/guides/files#.


Thanks,

Pranav

Login or Signup to post a comment