A
A
Al2017-06-19 02:19:15
Android
Al, 2017-06-19 02:19:15

Is it possible to mold an image file from the string passed in the request?

From the android client, the file is transferred to the server as a string, on the side of the android application this is done something like this:

InputStream inputStream = getContentResolver().openInputStream(uri);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder stringBuilder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
    stringBuilder.append(line);
}
model.setFileIcon(stringBuilder.toString());

Then the model is sent in a post-request to the server (using Volley). As a result, on the back, we have a variable in the form of a long string, we need to somehow recognize the mime type and put the contents in a file in a temporary folder with the necessary extension, and in general check that this is a picture and not something else.
How to do it with NodeJS? (Let's pretend it's not possible to change how the app sends a file, but if it's necessary, please suggest your solution.)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2017-06-19
@justru

Image in what format? if data-url , then everything is simple, it already has a mime and the body itself is correctly transmitted.
You can use this module to recode an image into a data-url on the backend

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question