ActiveStorage service_url generating logic

Hi there, I’m looking around to know how does active storage creates the service URL of any uploaded document to S3. I tried the guide by AWS Authenticating Requests: Using Query Parameters (AWS Signature Version 4) - Amazon Simple Storage Service It’s working fine but the uploaded file by active is extensionless and downloads the same file(i.e extensionless) but the link generated by active storage downloads with the correct file name.

Ex: File URL by Active Storage:; filename="uploaded_file.xlsx"; filename*=UTF-8''uploaded_file.xlsx&response-content-type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AAAAAAAAAAAAAAAAAAKEY/20201212/ap-south-1/s3/aws4_request&X-Amz-Date=20201212T112434Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=7fab73360c28b3f7f7d4e6d6893a2b91aa183c703ac890898e55845de44d917c

The one I generated using the above-mentioned URL which downloads the file but without extension and with the key instead of the actual name:

It looked to me that adding this in a string to sign might solve the problem but it didn’t. I looked around and got to know that it’s used to override response headers but I’m still looking for the correct way to generate the signature.

response-content-disposition=attachment; filename="uploaded_file.xlsx"; filename*=UTF-8''uploaded_file.xlsx&response-content-type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

may anyone help me with the signature key logic around this, please?

1 Like

Solved it! Had been stuck here because of a signature mismatch for 3 days! The issue was with encoding! Solved on own: python 3.x - AWS S3 Authenticating Requests Using Query Parameters to download file with custom name - Stack Overflow