Ok thanks ^^, I have no errors :) when i use CLI, only if i search the file but normal, my file is upload by a php form.
$ aws s3api head-object --bucket rankserver --key images/200x100.png
{
"AcceptRanges": "bytes",
"LastModified": "2021-12-23T09:55:42+00:00",
"ContentLength": 737,
"ETag": "\"948305774cd370326b142c7d5aee2d3d\"",
"ContentType": "image/png",
"Metadata": {}
}
My problem have changed, I can upload a file only if his name is the same of my file in my bucket ( uploaded manally ). ( I can find in the AWS CLI the file uploaded manually)
So, if you upload a file manually then you are able to upload a file with the same name using the php form, but if the file is not already in the bucket the upload with the php form fails. Did I understand correctly? If yes, what error do you get from in the php code?
Yes its that, I got the same error from my 1 post
Aws\S3\Exception\S3Exception Error executing "HeadObject" on "https://rankserver.s3.eu-west-3.amazonaws.com/images/200x100.png"; AWS HTTP error: Client error: `HEAD https://rankserver.s3.eu-west-3.amazonaws.com/images/200x100.png` resulted in a `404 Not Found` response NotFound (client): 404 Not Found (Request-ID: BG0058D586NR6CPC) -
Maybe this document can help you. There's a ton of information here on the HeadObject and it's permissions and use. Hope this helps, let me know if it does. https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html
Hello bukxy!
You can list the buckets in your account using the AWS CLI command:
aws s3 ls
You should see an output similar to this:
2019-11-26 15:43:45 bucketname1
2021-04-14 16:21:25 bucketname2
2021-04-14 16:13:48 bucketname3
2021-04-15 10:11:33 bucketname4
...
Once you confirmed that you have S3 buckets in your account and the bucket name you expected is in the list, run the following command to verify you have access to the bucket:
aws s3api head-bucket --bucket BUCKETNAME
(Please replace BUCKETNAME with the real bucket name you confirmed with the "aws s3 ls" command.)
If the bucket exists and you have access to it, no output is returned. Otherwise, an error will be shown.
For example:
A client error (404) occurred when calling the HeadBucket operation: Not Found
Once you confirmed the bucket exists and you have access to it, run the following command to check if the file exists:
aws s3api head-object --bucket BUCKETNAME -- key images/1/6PepdkQG3ZkfbBWjVr0jhoUotprRc5hMiNC78RE7.png
(Please replace BUCKETNAME with the real bucket name you confirmed with the "aws s3 ls" command.)
If the file exists you should have an output similar to this:
{
"AcceptRanges": "bytes",
"LastModified": "2020-12-22T23:43:04+00:00",
"ContentLength": 15522,
"ETag": "\"XXXXXXXXXXXXXXXXXXXXXXXXX\"",
"ContentType": "text/csv",
"Metadata": {}
}
If the file does not exist you should have an output similar to this:
An error occurred (404) when calling the HeadObject operation: Not Found
Here are are a few links to get you started:
- Installing the AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
- Configuring the AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
- Command head-bucket: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/head-bucket.html
- Command head-object: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/head-object.html
I hope this helps!
You might have a permission error. Do you have cloudtrail logs enabled?
If you do, you can go to the user here, and generate a policy based on the cloudtrail logs: https://console.aws.amazon.com/iamv2/home?#/users
If you don't have cloudtrail enabled, you can find information here on that: https://aws.amazon.com/cloudtrail/
Here a note on what cloudtrail can do for your account this way: https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-policy-generation.html
Let me know if this helps.
Relevant questions
I need to transfer objects from s3 bucket to another s3 in the same account
asked 5 days agoMove S3 buckets to different account
Accepted AnswerOld buckets reappear
asked 3 years agoI am getting CORS errors in S3 console, is this a bug with AWS S3?
asked 3 months agoMany buckets created by AWSConfig StackSet (required for SecurityHub)
Accepted Answerasked 5 months agoI can't use my s3 buckets
asked 8 months agoHow to use s3 life cycle policy for multiple buckets those starting with some fixed naming ?
asked a month agoHow can I find what S3 buckets are required by a service?
asked 5 months agoS3 + SSO permission to list a predefined list of buckets.
asked 2 months agoS3: Configure object lock with replication (CRR) on aws s3 buckets
asked 4 months ago
What kind of credentials are your using in your laravel? Are you using Instance profile? or IAM user keys? did you try aws cli to check if you can see the bucket using the same set of credentials?