Skip to content

Instantly share code, notes, and snippets.

@bogdan-nourescu
Created May 15, 2014 12:54
Show Gist options
  • Save bogdan-nourescu/7f52a07efeb1707ce971 to your computer and use it in GitHub Desktop.
Save bogdan-nourescu/7f52a07efeb1707ce971 to your computer and use it in GitHub Desktop.
public static void writeFile(GcsFilename gcsFileName, String content, String contentType) {
try {
GcsFileOptions options = new GcsFileOptions.Builder().mimeType(contentType).contentEncoding("UTF-8").build();
GcsService gcsService = GcsServiceFactory.createGcsService();
GcsOutputChannel writeChannel;
writeChannel = gcsService.createOrReplace(gcsFileName, options);
writeChannel.write(ByteBuffer.wrap(content.getBytes("UTF-8")));
writeChannel.close();
} catch (IOException e) {
Log.w(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment