Upload File using RestApi


I am trying to send a file using rest api from android.

Assume that there is a entity named ‘Fruits’.

Now, in fruits there is a variable with datatype FileRef.

Then, what will be the code to send the file to the server.
I am new to JMIX and till now I was send file by converting it to base64 string.

Thanks in advance.


Look at this section: Files API :: Jmix Documentation, it answers your question.


I read the documentation of Files API.

I was trying to use the direct files upload. But it is not working.

I get a successful response. But the an empty file is getting created on server side.

The command which I wrote is :

curl -X POST http://localhost:8080/rest/files?name=xyz.jpg -H "Authorization: Bearer " -H
“Content-Type: image/jpg” --data-binary “xyz.jpg”


Now I am able to send the file using the command.

The command is :
curl -X POST http://localhost:8080/rest/files -H "Authorization: Bearer " -H “Content-Type: image/jpeg” --data-binary “@”

But, now I have a new doubt.
This command helps to store file in default file storage location of the jmix.
I want to store it in different location.

Location is defined in AppApplication class, something like this :

FileStorage movieParentImage() {
return new LocalFileStorage(“asd”, “/homeImages/asd”);

Using the command how do i send file to the above location ?

Thanks in advance.

Use the storageName parameter of the /files endpoint.
See Swagger UI

Thanks. It Worked