Dont know how to code regarding Storing and retrieving files like Images,docs etc., in backendless

Are you looking for help?

This is a support forum for reporting issues related to Backendless services. Please note that due to our support policy we cannot provide you help with debugging your code, consulting in regards to any language or third-party library usage. For this kind of questions we recommend using more appropriate forums like Stack Overflow.

In order to suggest you a quality solution, we shall usually ask you to provide the details mentioned below first. Including them into your topic right away helps us to start investigating your issue much faster.

In case you have a suggestion or an idea, the details below are not always required, though still any additional background is welcome.

Backendless Version (3.x / 5.x, Online / Managed / Pro )

Client SDK (REST / Android / Objective-C / Swift / JS )

Application ID

Expected Behavior

Please describe the expected behavior of the issue, starting from the first action.

Actual Behavior

Please provide a description of what actually happens, working from the same starting point.

Be descriptive: “it doesn’t work” does not describe what the behavior actually is – instead, say “the request returns a 400 error with message XXX”. Copy and paste your logs, and include any URLs.

Reproducible Test Case

Please provide a simple code that could be run in a new clean app and reproduce the issue.

If the issue is more complex or requires configuration, please provide a link to a project on Github that reproduces the issue.

Take a look at the template text. It is there to make it easier for you to submit a support topic. Please read and provide the requested information.

I have done all the work for taking the images from the user’s device who is using my application and i have converted it into byteArray stream.
Now i need to store that particular image in one of the tables present in my backendless server.
I have got struck while coding for that thing.
So please help me with that for storing my files in backend and also how to retrieve that particular image without any errors.
Thanks in advance…

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(((requestCode == 1) && resultCode == RESULT_OK && (data != null)))
{
Uri selectedImage = data.getData();

        try {
            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();

Storing images in the database is not considered the best practice. We recommend storing images in the Files Storage. Here’s the API for storing a file on the server:
https://backendless.com/docs/android/file_save_files_from_byte_arrays.html

Once the file is stored on the server, the response is the URL of the file. You can then store that URL in the database if needed.

Downloading the file into your mobile app would require the same code as downloading a file from a URL. There are plenty of articles describing that. Here’s one for example, https://stackoverflow.com/questions/15758856/android-how-to-download-file-from-webserver

Mark