Programatically generating web console URL to s3 object - amazon-s3

Is there a way to generate urls to the s3 web console (https://s3.console.aws.amazon.com/s3/object/...) within python using botocore or boto3? I know boto can be used to generate presigned urls, but is there a way to just generate URL to the webconsole?

There is not a way in boto3 to generate the url but you can easily generate them yourself with variables and string formatting.
print("https://s3.console.aws.amazon.com/s3/buckets/{}?region={}&tab=objects".format("bucket_name", "us-east-1"))

Related

AWS Node SDK: How to generate a signed S3 getObject URL that doesn't include AccessKeyId

If one of my Selenium tests running in CircleCI fails, I upload a browser screenshot to S3 and print a signed getObject URL for it to the console, so that I can look up that screenshot quickly.
The problem is, S3.getSignedUrl adds my AWS AccessKeyId to the URL, and CircleCI is censoring it to ******************** since that value is in my environment variables, so the URL doesn't work:
https://s3.us-west-2.amazonaws.com/<bucket>/ERROR_3_reset_password_workflow_works.png
?AWSAccessKeyId=********************
&Expires=1612389785
&Signature=...
I don't see any options to output a different kind of URL in the getSignedUrl API docs. However, I noticed that when I open an image directly from the S3 console, the URL has a totally different form:
https://s3.us-west-2.amazonaws.com/<bucket>/ERROR_3_reset_password_workflow_works.png
?response-content-disposition=inline
&X-Amz-Security-Token=...
&X-Amz-Algorithm=AWS4-HMAC-SHA256
&X-Amz-Date=20210128T222508Z
&X-Amz-SignedHeaders=host
&X-Amz-Expires=300
&X-Amz-Credential=...
&X-Amz-Signature=...
Is there a way I can generate this type of URL with the S3 Node SDK? It doesn't use any values that CircleCI would censor, so it would work for what I'm trying to do.
I'm also looking into using CircleCI artifacts for the error screenshots, but I'd still like to understand how the S3 console is building the latter URL.
The Amazon S3 presignedURL examples here yield the format you're looking for. e.g.
[BUCKET]/[OBJECT]?X-Amz-Algorithm=[]&X-Amz-Content-Sha256=[]&X-Amz-Credential=[]&X-Amz-Date=[]&X-Amz-Expires=[]&X-Amz-Signature=[]&X-Amz-SignedHeaders=[]&x-amz-user-agent=[]
Note: These examples use V3 of the AWS SDK for JavaScript.

How to integrate API Gateway with S3 AWS Service using greedy path proxy resource

I have files in an S3 bucket that I am serving using AWS API Gateway
I have a resource GET /{file} that maps to mybucket:/{file}
ie http://myapigateway.com/test1.txt correctly returns mybucket:/test1.txt
Now I want to serve files with directory paths:
http://myapigateway.com/dirA/test2.txt should return the file mybucket:/dirA/test2.txt
I can not get this to work. The problem is that when I set the new API Gateway resource to use greedy path matches as a "proxy resource":
GET /{proxy+}
I no longer have the option to integrate with s3 (see image below)
I tried to pass the method.request.querystring.proxy var instead of method.request.path.proxy to prevent the slashes from being stripped but that didn't help.
If I can't integrate with s3 directly, is there any way I can work-around with a lambda function?
screen-shot: no option to integrate with AWS Service

Is an upload (put) object to AWS S3 from web browser possible?

But is a bit of a random question and no one should ever do it this way, but is it possible to execute a put api call to amazon S3 from the web browser? Using only query params.
For instance, ignoring authentication params, I know you can do https://s3.amazonaws.com/~some bucket~
To list files in the bucket. Is there a way to upload?
Have look at Browser-Based Uploads Using POST

Can we download a S3 file using javascript in browser?

I need to download a S3 file(in GBs) using javascript in a browser. Please let me know if it is possible and if there are any article with the sample code.
I was able to download the file using the pre signed URL.
http://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html
Steps:
1) Create a pre signed URL using the bucket, key name and the credential(Cognito).
2) Download the file using the pre signed URL. For downloading file using URL, We can find a lot of article online.

Uploading Multiple Images to Amazon s3 with HTML, javascript & jQuery with Ajax Request (No PHP or Server)

I am developing a website in HTML, javascript & jQuery. I want to upload (multiple images) to amazon s3 server in an ajax request. There is no such SDK to integrate s3 in Javascript. A PHP SDK is available, but it is not useful to me. Can anybody provide solution to this in javascript?
You can read the article - How to Upload Scanned Images to Amazon S3 Using Dynamic Web TWAIN, which introduces how to use PHP and JavaScript to upload files to Amazon S3. Key steps include:
Specify the bucket which is the place or the folder name used for
storing data on Amazon S3
Specify the Access Key and Secret Key you
obtained from your Amazon S3 account
Create a policy that specifies
what you permit and what you don’t permit for the data uploaded from a
client web page
Encode and encrypt these policies and signatures to
keep them confidential, and store the encoded and encrypted values in
the hidden input elements.