googleapis.storage.v1.objects.copy returns 404

 

 

 

    - copy_json_to_serving_bucket:
        call: googleapis.storage.v1.objects.copy
        args:
          destinationBucket: "target-bucket"
          destinationObject: "test_data/test.json"
          sourceBucket: "source-bucket"
          sourceObject: "test_data/test.json"
        result: copy_result

 

 

 

I ran into a 404 issue when leveraging workflow to copy one object from one bucket to another one. I verified that both buckets exist and the source object exist under `gs://source-bucket/test_data/test.json`, and the workflow SA has the access to read/write both buckets. The `insert` method works pretty well, but copy does not work, returning a 404 without much useful error inf

6 2 184
2 REPLIES 2

Ok i figured out the solution myself. Do this:

    - copy_json_to_serving_bucket:
        call: googleapis.storage.v1.objects.copy
        args:
          destinationBucket: "target-bucket"
          destinationObject: ${text.url_encode("test_data/test.json")}
          sourceBucket: "source-bucket"
          sourceObject: ${text.url_encode("test_data/test.json")}
        result: copy_result

The reason is that the api probably just does http REST call under the hood. And google did not url-encode the object path consistently with other APIs. 

For example, you shouldn't url_encode the `name` field under the `googleapis.storage.v1.objects.insert` API. 😳

`

 

 

 

amazing, this saved my day!