通过 cmis.zip下载文件



我目前正在开发一个原生的Android应用程序,并尝试访问文档服务器上的一些图片。为了交流,我正在使用OpenCMIS库。

我的目标是下载图片并将它们保存到设备的内部存储或SD卡中。我的问题是,是否有可能将文件下载为压缩存档,例如.zip并将其提取到设备上?因此,我想下载一个大文件,而不是单独下载很多文件。

这是OpenCMIS能够做到的吗?还是这取决于文档服务器?我正在使用SAP移动文档,并且知道我可以通过浏览器从Web界面下载整个文件夹作为.zip,但是我还没有发现在自定义Android客户端中

可以做到这一点。

任何提示或解释不胜感激,提前感谢!

所以我在Florian Müller的帮助下得到了它的工作。

对于任何喜欢的人来说,从原生Android应用程序中的SAP移动文档服务器下载文件夹作为.zip存档的最终代码如下所示:

public void downloadAsZip(Session session, Folder folder, File destination){
    ContentStream zipStream = session.getContentStream(folder, "sap:zipRendition", null, null);
    InputStream inputStream = zipStream.getStream();
    try {
        File file = new File(destination, folder.getName()+".zip");
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        byte[] buffer = new byte[1024];
        int bufferLength = 0;
        while ((bufferLength = inputStream.read(buffer)) > 0) {
            fileOutputStream.write(buffer, 0, bufferLength);
        }
        fileOutputStream.close();
        inputStream.close();
    }
    catch(IOException e){
        Log.e(TAG, "An error occurred: "+e.getMessage());
    }
}

最新更新