1

I wrote an android application that part of it is to handle upload and download documents. Currently I am using the Microsoft Azure server to save the files on.

The way I am currently doing it is by turning the files to a string and saving it that way on the Azure server:

ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileInputStream fis;
try {
      fis = new FileInputStream(new File(Uridata.getPath()));
      byte[] buf = new byte[1024];
      int n;
      while (-1 != (n = fis.read(buf)))
             baos.write(buf, 0, n);
} catch (Exception e) {
       e.printStackTrace();
}
byte[] bbytes = baos.toByteArray();
item.setStringFile(Base64.encodeToString(bbytes, Base64.URL_SAFE));
item.setName(Uridata.getLastPathSegment());

where item is my class that saves the string representation and the name of the file and is being loaded to the Azure, Uridata is an Uri instance of the file chosen.

I have one main problem with this solution and it is the limit on the file size. I am searching for a good server to use instead of the Azure (maybe a RESET one) and if there is a better way to save files of all kinds (pdf, word...).

I will also want in the future to use the same data in a web interface

Does anybody have any suggestions on how to do it?

Thanks in advance!

Avner Gidron
  • 411
  • 5
  • 13

1 Answers1

0

To start, you don't have to transform the file into a string, you can just save it as a file. You have the possibility of losing data by continuing to do that. See: How do I save a stream to a file in C#?

If you're looking for another service to save files, then you should look into Azure Blob Storage. It will allow you to upload as much data as you want to a storage service for arbitrary files. See for example: https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/

Community
  • 1
  • 1
theadriangreen
  • 2,218
  • 1
  • 14
  • 14