0

I use python boto3 when I upload file to s3,aws lambda will move the file to other bucket,I can get object url by lambda event,like https://xxx.s3.amazonaws.com/xxx/xxx/xxxx/xxxx/diamond+white.side.jpg

The object key is xxx/xxx/xxxx/xxxx/diamond+white.side.jpg This is a simple example,I can replace "+" get object key, there are other complicated situations,I need to get object key by object url,How can I do it? thanks!!

2 Answers 2

1

You should use urllib.parse.unquote and then replace + with space.

From my knowledge, + is the only exception from URL parsing, so you should be safe if you do that by hand.

Sign up to request clarification or add additional context in comments.

Comments

0

I think this is what you want:

url_data = "https://xxx.s3.amazonaws.com/xxx/xxx/xxxx/xxxx/diamond+white.side.jpg".split("/")[3:]
object_key = "/".join(url_data)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.