1

I'm writing a byte-array from an image to Google Cloud Storage, how do I prevent accidentally overwriting some other file in GCS and how do I retreive the blobKey after I've written this byte-array to GCS?

GcsFilename fileName = new GcsFilename("my-bucket-name", "someFileName.jpg");
GcsOutputChannel outputChannel = GcsServiceFactory.createGcsService().createOrReplace(fileName, GcsFileOptions.getDefaultInstance());
outputChannel.write(ByteBuffer.wrap(bytearray));
outputChannel.close();
Jan Vladimir Mostert
  • 12,380
  • 15
  • 80
  • 137

0 Answers0