【发布时间】:2016-02-11 00:16:57
【问题描述】:
我写了一个安卓应用程序,其中一部分是处理上传和下载文件。目前我正在使用 Microsoft Azure 服务器来保存文件。
我目前的做法是将文件转换为字符串并将其保存在 Azure 服务器上:
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());
其中 item 是我的类,它保存字符串表示形式和文件名并正在加载到 Azure,Uridata 是所选文件的 Uri 实例.
我对这个解决方案有一个主要问题,那就是文件大小的限制。 我正在寻找一个好的服务器来代替 Azure(可能是一个 RESET ),如果有更好的方法来保存各种文件(pdf、word...)。
我还希望将来在 Web 界面中使用相同的数据
有人对如何做有任何建议吗?
提前致谢!
【问题讨论】:
标签: android file rest azure server