Cannot delete files in Cloud Storage

Asked 2 years ago, Updated 2 years ago, 116 views

When I try to delete an image that I upload to Cloud Storage, I get the following error and I cannot delete it.

Aws\S3\Exception\S3Exception
Error executing "ListObjects" on "myproject.appspot.com" AWS HTTP error: Client error: `GET myproject.appspot.com` resulted in a `400 Bad Request` response: <?xml version='1.0' encoding='UTF-8'?><Error><Code>InvalidArgument</Code><Message>Invalid argument.</Message><Details>In (truncated...) InvalidArgument (client): Invalid argument. -<?xml version='1.0' encoding='UTF-8'?>Error><Code>InvalidArgument</Code>Message>Invalid argument.</Message>Details>Detail&query] [Invalid arcing]

I am currently using Ravel's FileSystem to communicate with Cloud Storage.
The image has been uploaded with the following code.

$fileName='article/'.uniqid(mt_land());
$disk=Storage::disk('gcp');
$disk->put($fileName,file_get_contents($image)));

And the deletion is as follows:

Storage::disk('gcp')->delete([$filePath->image]);

$filePath->image contains a full path such as https://storage.googleapis.com/myproject.appspot.com/article/123456abcd.
Why can't I delete it even though I can upload it?
Do I have to set up any settings to delete the data in Cloud Storage?
Please let me know if anyone knows.Thank you for your cooperation.

php laravel google-cloud-storage

2022-09-29 21:39

1 Answers

The prefix you specified includes "https://..."
It should just include the object name prefix, not the full URL.

Also, is myproject.appspot.com the name of your bucket?I'm wondering if you want that to indicate the project name.

Also, there is no encoding-type parameter for this request.

The documentation is at https://cloud.google.com/storage/docs/xml-api/get-bucket-list


2022-09-29 21:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.