public URL generateV4GPutbjectSignedUrl(String bucketName, String objectName)
      throws StorageException {
    // [START storage_generate_upload_signed_url_v4]
    // Instantiate a Google Cloud Storage client
    Storage storage = StorageOptions.getDefaultInstance().getService();

    // The name of a bucket, e.g. "my-bucket"
    // String bucketName = "my-bucket";

    // The name of a new object to upload, e.g. "my-object"
    // String objectName = "my-object";

    // Define Resource
    BlobInfo blobinfo = BlobInfo.newBuilder(BlobId.of(bucketName, objectName)).build();

    // Generate Signed URL
    Map<String, String> extensionHeaders = new HashMap<>();
    extensionHeaders.put("Content-Type", "application/octet-stream");

    URL url =
        storage.signUrl(
            blobinfo,
            15,
            TimeUnit.MINUTES,
            Storage.SignUrlOption.httpMethod(HttpMethod.PUT),
            Storage.SignUrlOption.withExtHeaders(extensionHeaders),
            Storage.SignUrlOption.withV4Signature());

    System.out.println("Generated PUT signed URL:");
    System.out.println(url);
    System.out.println("You can use this URL with any user agent, for example:");
    System.out.println(
        "curl -X PUT -H 'Content-Type: application/octet-stream'--upload-file my-file '"
            + url
            + "'");
    // [END storage_generate_upload_signed_url_v4]
    return url;
  }
public URL generateV4GPutbjectSignedUrl ( String bucketName , String objectName ) throws StorageException { Storage storage = StorageOptions . getDefaultInstance ( ) . getService ( ) ; BlobInfo blobinfo = BlobInfo . newBuilder ( BlobId . of ( bucketName , objectName ) ) . build ( ) ; Map < String , String > extensionHeaders = new HashMap < > ( ) ; extensionHeaders . put ( "Content-Type" , "application/octet-stream" ) ; URL url = storage . signUrl ( blobinfo , 15 , TimeUnit . MINUTES , Storage . SignUrlOption . httpMethod ( HttpMethod . PUT ) , Storage . SignUrlOption . withExtHeaders ( extensionHeaders ) , Storage . SignUrlOption . withV4Signature ( ) ) ; System . out . println ( "Generated PUT signed URL:" ) ; System . out . println ( url ) ; System . out . println ( "You can use this URL with any user agent, for example:" ) ; System . out . println ( "curl -X PUT -H 'Content-Type: application/octet-stream'--upload-file my-file '" + url + "'" ) ; return url ; }
Example of how to generate a PUT V4 Signed URL