Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

google cloud storage presigned url is not working

New Here ,
Nov 16, 2023 Nov 16, 2023

I followed the exmaple implementation for AWS s3 to create signedUrl. Instead of AWS, I want to use Google cloud storage. But unfortunately, I am getting "'HTTP PUT failed, RetryException: PUT'" error in the errorDetail field of the response.
I executed a PUT request on returning the URL in the "output" section of the response. It worked. The error message is very poorly designed and doesn't provide any other details or directions to follow. 

It would be nice to get support on this:

Function to generate signed_url:

def get_presigned_url(bucket_name, path, operation, expires_in=3600):
    """
    Generates a presigned URL for a Google Cloud Storage object.

    :param bucket_name: The name of the GCS bucket.
    :param path: The name of the blob in the GCS bucket.
    :param operation: The operation ('read' or 'write').
    :param expires_in: Expiration time in seconds.
    :return: A presigned URL.
    """
    storage_client = storage.Client()
    bucket = storage_client.bucket(bucket_name)
    blob = bucket.blob(path)

    if operation == 'read':
        url = blob.generate_signed_url(
            version="v4",
            expiration=timedelta(seconds=expires_in),
            method="GET"
        )
    elif operation == 'write':
        url = blob.generate_signed_url(
            version="v4",
            expiration=timedelta(seconds=expires_in),
            method="PUT",
            content_type='application/octet-stream'
        )
    else:
        raise ValueError("Operation must be 'read' or 'write'.")

    return url

 

def api_call(image: Image) -> Image:
    image_bytes = imageToBytes(image)
    
    original_file_name = f"raw_images/original.png"
    
    upload_bytes_to_gcs(bucket, image_bytes, original_file_name)
    
    new_original_file_name = f"processed_images/original.png"

    input_scr_url = get_presigned_url(bucket, original_file_name, 'read')
    output_dest_url = get_presigned_url(bucket, new_original_file_name, 'write')


    headers = {"Authorization": f"Bearer {token}", "x-api-key": client_id}
    payload = {
        "inputs": {
            "href": input_scr_url,
            "storage": "external"
        },
        "outputs": [
            {
                "href": output_dest_url,
                "storage": "external",
                "type": "image/png"
            }
        ]
    }

    resp = invoke_autotone(autotone_url, headers, payload)
    status = poll_status(resp, headers)
    print(status)



TOPICS
PS Automation API
527
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Dec 11, 2023 Dec 11, 2023

Hi there, 

We have some instructions in our documentation that might be able to help you with this problem.  Go to the section that is labeled Google Drive and follow the instructions there. I fyou get stuck and still need assistance I would recomend opening a support ticket. You can open a new case here. 
https://developer.adobe.com/photoshop/photoshop-api-docs/general-workflow/#input-and-output-file-storage

Translate
Adobe Employee ,
Dec 11, 2023 Dec 11, 2023

Hi there, 

We have some instructions in our documentation that might be able to help you with this problem.  Go to the section that is labeled Google Drive and follow the instructions there. I fyou get stuck and still need assistance I would recomend opening a support ticket. You can open a new case here. 
https://developer.adobe.com/photoshop/photoshop-api-docs/general-workflow/#input-and-output-file-sto...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 23, 2024 Aug 23, 2024
LATEST

Hello,

 

following on this case, I also support considering Google Cloud Storage support (like Azure Storage and AWS S3).

Google Drive is not exactly the same, even if it is an interesting option for Google Cloud file storage option.

 

I have used Google Cloud Storage presigned URL to send images to the API and it is working fine.

 

But the uploading of the result by Photoshop API fails with a presigned URL.

The error message from Google is the following one:

<Error>
<Code>MalformedSecurityHeader</Code>
<Message>Invalid argument.</Message>
<Details>
Your request has a malformed header. Header was included in signedheaders, but not in the request.
</Details>
<ParameterName>content-type</ParameterName>
</Error>

It would be a good improvement to  support this, to have all cloud providers on par.

Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines