存储 box 或 dropbox 文件
Store a box or dropbox file
我正在编写一个 App Engine 应用程序,它可以访问 box 和 dropbox api。
我想将文件保存到 google 云存储中。它们都将 FileOutPutStream 作为要下载文件的输出流。
DropBoxAPI :
FileOutputStream outputStream = new FileOutputStream("magnum-opus.txt");
}try {
DbxEntry.File downloadedFile = client.getFile("/magnum-opus.txt", null,
outputStream);
System.out.println("Metadata: " + downloadedFile.toString());
}finally {
outputStream.close();
框API:
BoxFile file = new BoxFile(api, "id");
BoxFile.Info info = file.getInfo();
FileOutputStream stream = new FileOutputStream(info.getName());
file.download(stream);
stream.close();
App 引擎已禁用输出流。我该如何解决这个问题?我应该为输出流使用什么?提前致谢。
你没有说你想写什么到云存储,所以我假设你已经有了一些你想写的内容,在这种情况下 Google 云存储客户端 API (javadoc) 应该能满足您的需求。
特别是 GcsOutputChannel
。这允许您使用字节缓冲区或输出流写入 GCS 中的指定位置。
例如(from here):
GcsOutputChannel channel =
gcsService.createOrReplace(fileName, GcsFileOptions.getDefaultInstance());
ObjectOutputStream out = new ObjectOutputStream(Channels.newOutputStream(channel));
out.writeObject(content);
out.close();
我正在编写一个 App Engine 应用程序,它可以访问 box 和 dropbox api。 我想将文件保存到 google 云存储中。它们都将 FileOutPutStream 作为要下载文件的输出流。 DropBoxAPI :
FileOutputStream outputStream = new FileOutputStream("magnum-opus.txt");
}try {
DbxEntry.File downloadedFile = client.getFile("/magnum-opus.txt", null,
outputStream);
System.out.println("Metadata: " + downloadedFile.toString());
}finally {
outputStream.close();
框API:
BoxFile file = new BoxFile(api, "id");
BoxFile.Info info = file.getInfo();
FileOutputStream stream = new FileOutputStream(info.getName());
file.download(stream);
stream.close();
App 引擎已禁用输出流。我该如何解决这个问题?我应该为输出流使用什么?提前致谢。
你没有说你想写什么到云存储,所以我假设你已经有了一些你想写的内容,在这种情况下 Google 云存储客户端 API (javadoc) 应该能满足您的需求。
特别是 GcsOutputChannel
。这允许您使用字节缓冲区或输出流写入 GCS 中的指定位置。
例如(from here):
GcsOutputChannel channel =
gcsService.createOrReplace(fileName, GcsFileOptions.getDefaultInstance());
ObjectOutputStream out = new ObjectOutputStream(Channels.newOutputStream(channel));
out.writeObject(content);
out.close();