How to create cloudfront signed URL from mobile app?

0

I can achieve it thorough java in my mobile app but it is insecure to store the secret key in the client side. Attackers can harm the server. So what is the best way to create singed URL for mobile apps?

I want signed URL of list of videos for my feed like youtube. What is the best way to achieve that? Please provide some code.

1개 답변
0
수락된 답변

There are several ways to do this here is one.

To create a signed URL for an Amazon S3 object in Python, you can use the boto3 library and the client.generate_presigned_url() method. This method allows you to create a URL that you can share with others that provides temporary access to download or upload an object in your bucket.

Here is an example of how you can use generate_presigned_url() to create a signed URL that allows a user to download an object from your bucket: (If you used this code as a lambda function or with secrets manager you would not need to embed credentials)

import boto3

# Replace ACCESS_KEY and SECRET_KEY with your Amazon S3 access key and secret key
s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY)

# Replace BUCKET_NAME and OBJECT_KEY with the name of your bucket and the key of the object you want to create a signed URL for
url = s3.generate_presigned_url(
    ClientMethod='get_object',
    Params={
        'Bucket': BUCKET_NAME,
        'Key': OBJECT_KEY
    }
)

print(url)

If you need help generating code for most languages I suggest using CodeWhisperer, which is in free preview. https://aws.amazon.com/codewhisperer/

profile pictureAWS
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠