How to send empty file in android Volley Multi-part along with the other headers

766 Views Asked by At

I am working on Volley Multipart to upload images to server. for that I am using

mBuilder.addBinaryBody(headerKeyName, file, ContentType.create("image/jpg"),FILEPATH);

Now I have to send the empty file along with some headers. how can I use that method for empty file.

Please someone help me.

1

There are 1 best solutions below

6
tebitoq On

Hi you can do something like this:

         File file = new File("path");

            try {  
              if (file.createNewFile()) {    
               mBuilder.addBinaryBody(headerKeyName, file,ContentType.create("image/jpg"), file.getAbsoluteFile());
              }
            } catch (IOException e) {
               e.printStackTrace();
            }

Regards.