Irfan UllahOriginal post
Rank 1: Thread
The docs mention that the HeadObject request is supported, but when I try to call it, I’m getting a 403 error. I’ve tried it with both boto3 and the AWS CLI, and I’m seeing the same issue with both.
Python
import boto3from botocore.config import Configcreds = {}# 1. Initialize your client with explicit S3 settingsclient = boto3.client( 's3', # For Appwrite Cloud use 'https://appwrite.io' # For Self-hosted use 'https://YOUR_HOST/v1/s3' endpoint_url=creds.get("endpoint_url"), # Credentials mapping for Appwrite aws_access_key_id=creds.get("aws_access_key_id"), aws_secret_access_key=creds.get("aws_secret_access_key"), # Must use 'us-east-1' (or a placeholder) so signature signing operates correctly region_name=creds.get("region_name"), # CRITICAL: Force path-style addressing and require standard SigV4 signing config=Config( s3={'addressing_style': 'path'}, signature_version='s3v4' ))
# 2. Test your calltry: # In Appwrite, 'Bucket' is your Appwrite Bucket ID, 'Key' is your File ID response = client.head_object(Bucket="bucketname", Key="filename.json") print("Success:", response)except Exception as e: print("Error:", e)Bash
An error occurred (403) when calling the HeadObject operation: ForbiddenSummary
User is getting a 403 Forbidden error when trying to call the `HeadObject` operation in S3 using both boto3 and AWS CLI.
**Solution:** The error might be due to missing permissions. Ensure that the IAM user or role has the necessary permissions (such as `s3:GetObject`) to perform the `HeadObject` operation. Also, correctly set up the client, endpoint URL, credentials, region name, and configuration when initializing the boto3 client.