Backendless.Files.saveFile( “testfolder”, “fox.txt”, byteArray, true )
.then( function( savedFileURL ) {
console.log( "file has been saved - " + savedFileURL );
})
.catch( function( error ) {
console.log( "error - " + error.message );
});
when iam executing the above code in my IDE it was throwing an error…
Bitmap bit = MediaStore.Images.Media.getBitmap(this.getContentResolver(),selectedImage);
ivImage.setImageBitmap(bit);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bit.compress(Bitmap.CompressFormat.PNG,100,stream);
byte[] byteArray = stream.toByteArray();
Backendless.Files.saveFile("Images","image.png",byteArray,true)
.then(function(savedFileURL))
{
console.log("file has been saved",+savedFileUrl);
})
.catch(function(error))
{
console.log("error");
}
And the main problem i am facing is i am not getting how to make an image/file(any type) to save in backend and how to retrieve it. I am unable to code for that particular thing using backendless.
And also after uploading the file in server, i want to place images of particular user in single row only not in the new rows.
Please help me with that i am going through almost all the documentations in backendless though i am not finding the solution.
Thanks in advance…
Hello @SIVAKUMAR_REDDY
What kind of error are you getting? Could you please share with us error stack trace?
Regards, Vlad
And the main problem i am facing is i am not getting how to make an image/file(any type) to save in backend and how to retrieve it. I am unable to code for that particular thing using backendless.
And also after uploading the file in server, i want to place images of particular user in single row only not in the new rows.
Please help me with that i am going through almost all the documentations in backendless though i am not finding the solution.
you wrote this:
I believe if we see the error we will be able to help with solving this issue
and also seems you mixed Android-SDK with JS-SDK, didn’t you?
here is an example for uploading files using Android SDK https://backendless.com/docs/android/file_save_files_from_byte_arrays.html#example
yeah, now I see,
then
keyword comes from JS, not from Java, take a look at my previous comment
I have done this but the app stops anonymously…
And also it is not inserting in the backend.
try to debug and figure out what’s going there on the device before it crashes
You’re using a blocking API call on the main UI thread. Android doesn’t allow it and that’s most likely the reason why the app stops. See the following section from our documentation:
https://backendless.com/docs/js/sync_and_async_calls.html
Specifically the IMPORTANT
block at the botto of the page.
Mark
I don’t know how to use non-blocking API for my code which uploads images/files.
And also you are suggesting me to see the JS related code.
But i am working on Android-SDK.
It was throwing the error like this after uploading image in my application.
What does it mean?
What i have to do for that thing?
For now you can add the following code in the main activity - right after Backendless.initApp
:
Backendless.UserService.logout( new AsyncCallback<Void>()
{
public void handleResponse( Void response )
{
// user has been logged out.
}
public void handleFault( BackendlessFault fault )
{
}
});