Reputation: 623
I am writing an app engine app which has access both to box and dropbox api. I want to save the file into the google cloud storage. Both of them have the FileOutPutStream as the output stream for the file to download. 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();
Box API:
BoxFile file = new BoxFile(api, "id");
BoxFile.Info info = file.getInfo();
FileOutputStream stream = new FileOutputStream(info.getName());
file.download(stream);
stream.close();
App engine has outputstreams disabled. How can I solve this? What should i use for outputstream? Thanks in advance.
Upvotes: 0
Views: 215
Reputation: 3564
You don't say what you're trying to write to Cloud Storage, so I will assume you already have some content that you want to write, in which case the Google Cloud Storage Client API (javadoc) should give you what you're looking for.
In particular, GcsOutputChannel
. This allows you to write to a specified location in GCS using a byte buffer or output stream.
e.g. (from here):
GcsOutputChannel channel =
gcsService.createOrReplace(fileName, GcsFileOptions.getDefaultInstance());
ObjectOutputStream out = new ObjectOutputStream(Channels.newOutputStream(channel));
out.writeObject(content);
out.close();
Upvotes: 2