question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

method generate_url (get temporary url)

See original GitHub issue

With boto library (not boto3), there is method generate_url which generates temporary url for given object. This method is availabe on connection, bucket and key objects.

import boto
con = boto.connect_s3()
tmpurl_c = con.generate_url(...)
bucket = con.get_bucket("mybucket")
tmpurl_b = bucket.generate_url(...)
key = bucket.get_object("key/name.txt")
tmpurl_k = key.generate_url(...)

I was unable to find corresponding method in boto3. Is there such a method? Or is it planned?

I am aware, that actually creating the temporary url is not a call to AWS web service (so I do not expect it to be found in AWS serices model), but for practical use it is very important.

Fortunatelly, today we may se boto to do this work, but if boto3 is supposed to be complete replacement to today boto, ability to generate temporary url seems to be important.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

22reactions
radAragoncommented, Sep 15, 2015

Faerloev,

The ClientMethod param is not clearly described, but it just means a Client method like the “get_object” (http://boto3.readthedocs.org/en/latest/reference/services/s3.html?highlight=s3 url#client). Here’s my example:

        client = boto3.client('s3')
        bucket_name = 'api_reports'

        resp = client.put_object(
                                Bucket= bucket_name, 
                                Key= filename, 
                                Body= file,
                                Expires= datetime.utcnow() + timedelta(days=7), )
        print(resp)
        url = client.generate_presigned_url(
                                            'get_object', 
                                            Params = { 
                                                      'Bucket': bucket_name, 
                                                      'Key': filename, }, 
                                            ExpiresIn = 86400, )
        print(url)
1reaction
faerloevcommented, Sep 11, 2015

Mjello,

I’m in the same boat as @niallatbynder ; I can’t seem to figure out how generate a signed url.

CloudFront.Client.generate_presigned_url() takes a ClientMethod argument, but fails to describe what this ClientMethod can be. From my trails I get the impression, that ClientMethod should be a method on CloudFront.Client, is that correctly understood? In that case, I can’t find any methods on CloudFront.Client that fetches a file from a bucket, hence no methods to generate a signed url for.

An example of how to use this would be greatly appreciated.

Thanks in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sharing objects using presigned URLs - AWS Documentation
Describes how to set up your objects so that you can share them with others by creating a presigned URL to download the...
Read more >
URL Generation - The PHP Framework For Web Artisans
If you would like to generate a temporary signed route URL that expires after a specified amount of time, you may use the...
Read more >
Generate temporary signed URL from s3 in Laravel
To create temporary files, you can use temporaryUrl method from the Illuminate\Support\Facade\Storage facade. You can use the method on the ...
Read more >
How to generate url from boto3 in amazon web services
I am using boto3 and boto3 doesn't seem to have an implemented generate url method. They have a core method, that generates url...
Read more >
temporary url middleware - Object Storage Service - Z.com
You need to create a URL after registrating Temp-Url-Key. The procedure is as follows. ・Create a script to generate URL ・Use Swift-temp-url client....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found