Storage service should manage resumeable signedURL uploads (original) (raw)

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:

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);