0

In order to delete a file from S3 with given a file url like https://user-files.s3.us-east-1.amazonaws.com/1234-5678/image.png, is there a way to delete the file using the url?

If bucket and key are a must, is there an official way to extract them from the URL?

I dont want to assume anything about the url because if in the future ill use forcePathStyle the url will look differently (it will look like s3.us-east-1.amazonaws.com/user-files/1234-5678/image.png, and in this case the bucket name doesnt resides in the hostname). So trying to avoid string manipulations (e.g url.hostname.split(".")[0]).

Benny67b
  • 509
  • 1
  • 6
  • 18
  • just don't use forcePathStyle. IIRC Amazon doesn't want you to use this style anyway, because it can't direct certain buckets to certain IP addresses. – user253751 May 12 '23 at 12:05
  • Why do you have an HTTP URL in the first place, rather than a bucket/key pair? – jarmod May 12 '23 at 13:26

0 Answers0