humanmade / humanmade/S3-Uploads

getObjectAttributes() still downloads full file and Error parsing XML

Open
#598 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
2.2k
Forks
404
PR merge metrics
No merged PRs in 30d

Description

Hi there,

I'm trying to use $s3->getObjectAttributes() to grab a file's ETag but I see two issues with this. It seems (based on bandwidth) that this command still downloads the whole file which beats the purpose of just getting the attributes. Secondly, I'm getting an error.

The code and command I'm using:
```
$s3 = S3_Uploads\Plugin::get_instance()->s3();
try {
$data = $s3->getObjectAttributes(
[
'Bucket' => S3_UPLOADS_BUCKET,
'Key' => $key,
'ObjectAttributes' => array('ETag')
]
);
...
```
This gives me an error:
> "Error parsing response for GetObjectAttributes: AWS parsing error: Error parsing XML: String could not be parsed as XML"

My S3 provider is us-east-1.linodeobjects.com and I'm on version "humanmade/s3-uploads": "3.0.4".
I think it's also good to know that if I use $s3->getObject() the command works and I get the Guzzle stream as well as ETag, etc. (but my goal here is not to download the file).

If I change the 'ObjectAttributes' to `'ObjectAttributes' => array('ETag', 'ObjectSize')` then it immediately fails with:
> "Error executing "GetObjectAttributes" on "path?attributes"; AWS HTTP error: Client error: `GET https://path?attributes` resulted in a `403 Forbidden` response:
> SignatureDoesNotMatchtx00000000000001b570a59-0062fe (truncated...)

Hopefully someone can help me out, thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the getObjectAttributes() call reached through S3_Uploads\Plugin::get_instance()->s3(), and compare its request and response handling with the working getObject() call. Reproduce against the us-east-1.linodeobjects.com provider using the reported ObjectAttributes values; done means attributes are returned without downloading the full object and the response parses successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, php
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.