-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
google-cloud-java currently allows users to mint a signedURL but offers not way to separately manage the resumable upload given just the signedURL.
The usecase for this is if i have in possession a signedURL that allows for resumeable uploads, i'd like to use google-cloud-java to manage the transfer for me.
some background:
-
a resumable transfer session requires a special header to get it going (
x-goog-resumable: start) as described here. At the moment, our java libraries do not support baking in the canonical headers into the signedURL. see issue#2000 -
Even if we do support a signeURL that allows for the transfer initiation, i didn't see anyplace within the library which will manage that transfer for you (i.,e handle retries, partial transfers, etc) given just a signedURL. It does appear that resumeable uploads are supported but that appears to be about authenticated uploads (not signedURL)
my 2c on how this may look
create a signedURL somewhere else and provide a header to allow the uploads
Storage storage_service = StorageOptions.newBuilder()
.setCredentials(ServiceAccountCredentials.fromStream(new FileInputStream("svc_acct.json")))
.build()
.getService();
BlobId blobId = BlobId.of(bucketName, objectName);
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType(content_type).build();
SignUrlOption opts = SignUrlOption.withContentType() // (+new way to add headers:("x-goog-resumable:start")
URL signedUrl = storage_service.signUrl(blobInfo, 60, TimeUnit.SECONDS, opts);then on the client, google-cloud-java would upload an object without needed authentication...and manage the retry on resume.
Storage storage_service_no_creds = StorageOptions.newBuilder()
.setCredentials(NoCredentials.getInstance())
.build()
.getService();
storage_service_no_creds.create(blobInfo, "filecontent".getBytes(UTF_8), signedUrl);