amazon-s3

Boto3 get only S3 buckets of specific region

安稳与你 提交于 2020-02-03 10:11:46
问题 The following code sadly lists all buckets of all regions and not only from "eu-west-1" as specified. How can I change that? import boto3 s3 = boto3.client("s3", region_name="eu-west-1") for bucket in s3.list_buckets()["Buckets"]: bucket_name = bucket["Name"] print(bucket["Name"]) 回答1: s3 = boto3.client("s3", region_name="eu-west-1") connects to S3 API endpoint in eu-west-1 . It doesn't limit the listing to eu-west-1 buckets. One solution is to query the bucket location and filter. s3 = boto3

Is boto3.Bucket.upload_file blocking or non-blocking?

巧了我就是萌 提交于 2020-02-03 05:17:05
问题 Is boto3.Bucket.upload_file blocking or non-blocking? i.e. if I were to run the following bucket = session.Bucket(bucket_name) bucket.upload_file(Key=s3_key, Filename=source_path) os.remove(source_path) Do I have a race condition, depending on the size of the file? Or is upload guaranteed to complete before file deletion? 回答1: The current boto3 upload_file is blocking. As mootmoot said, you should definitely implement some error handling to be safe if you delete the file. 回答2: The fact upload

OptionsRequestDenied When Uploading File to S3

别来无恙 提交于 2020-02-03 04:09:10
问题 When I try to upload a JS file to S3, I get the upload error: OptionsRequestDenied. All the other files, including the JS ones have worked except this one. The file makes some cross-origin requests using jQuery like this: function corsRequest(callback){ $.get("www.example.com", function(data, status){ callback(data); }) } setInterval(corsRequest, 5000); I've tried changing the CORS settings to allow all methods: <?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration xmlns="http://s3

Basic User Authentication for Static Site using AWS & S3 Bucket

笑着哭i 提交于 2020-02-02 16:31:26
问题 I am looking to add Basic User Authentication to a Static Site I will have up on AWS so that only those with the proper username + password which I will supply to those users have access to see the site. I found s3auth and it seems to be exactly what I am looking for, however, I am wondering if I will need to somehow set the authorization for pages besides the index.html. For example, I have 3 pages- index, about and contact.html, without authentication setup for about.html what is stopping

AWS Which IAM Role For S3 Presigned URL

自闭症网瘾萝莉.ら 提交于 2020-02-02 15:22:11
问题 I am deploying a server program in an ec2 instance which needs to be able to create pre-signed urls for s3. So far I've had my AWS credentials in environment variables for testing, but I would like to switch to the IAM Role strategy now. However, I am unsure as to which policies the role should have access too. My initial guess is to have AmazonS3FullAccess, but the description says "Provides full access to all buckets via the AWS Management Console" but the ec2 instance will be using the c++

Canvas tainted by CORS data and S3

你。 提交于 2020-02-02 06:10:47
问题 My application is displaying images stored in AWS S3 (in a private bucket for security reasons). To allow users to see the images from their browser I generate signed URLs like https://s3.eu-central-1.amazonaws.com/my.bucket/stuff/images/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=...&X-Amz-Date=20170701T195504Z&X-Amz-Expires=900&X-Amz-Signature=bbe277...3358e8&X-Amz-SignedHeaders=host . This is working perfectly with <img src="S3URL" /> : the images are correctly displayed. I

Grant S3 access to Elastic Beanstalk instances

喜夏-厌秋 提交于 2020-02-01 18:58:46
问题 I'm trying to provision my EC2 instances in Elastic Beanstalk with some ssh keys from a private S3 bucket. Here's a snippet of my .ebextensions/.config: files: "/root/.ssh/id_rsa" : mode: "000400" ownder: root group: root source: https://s3-us-west-2.amazonaws.com/<bucket>/<app>_id_rsa Unfortunately, I'm getting a 403 response from S3. Is there a way to grant access to the EC2 instances using a Security Group? I can't grant each instance access individually as I won't know their IPs before

Multiple images upload to Bucket AWS S3 using swift

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-01 08:46:21
问题 I am tryin to upload an image to bucket AWS s3 using below code. let ext = "jpeg" let uploadRequest = AWSS3TransferManagerUploadRequest() uploadRequest?.acl = .publicRead uploadRequest?.body = URL(fileURLWithPath: path) uploadRequest?.key = s3BucketKey uploadRequest?.bucket = S3BucketName uploadRequest?.contentType = "image/" + ext DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async { let transferManager = AWSS3TransferManager.default() transferManager.upload(uploadRequest!)

Multiple images upload to Bucket AWS S3 using swift

依然范特西╮ 提交于 2020-02-01 08:46:08
问题 I am tryin to upload an image to bucket AWS s3 using below code. let ext = "jpeg" let uploadRequest = AWSS3TransferManagerUploadRequest() uploadRequest?.acl = .publicRead uploadRequest?.body = URL(fileURLWithPath: path) uploadRequest?.key = s3BucketKey uploadRequest?.bucket = S3BucketName uploadRequest?.contentType = "image/" + ext DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async { let transferManager = AWSS3TransferManager.default() transferManager.upload(uploadRequest!)

Using S3 as a database vs. database (e.g. MongoDB)

你离开我真会死。 提交于 2020-02-01 00:32:39
问题 Due to simple setup and low costs I am considering using AWS S3 bucket instead of a NoSQL database to save simple user settings as a JSON (around 30 documents). I researched the following disadvantages of not using a database which are not relevant for my use case: Listing of buckets/files will cost you money. No updates - you cannot update a file, just replace it. No indexes. Versioning will cost you $$. No search No transactions No query API (SQL or NoSQL) Are there any other disavantages