amazon-s3

Write to S3 bucket using Async/Await in AWS Lambda

允我心安 提交于 2021-02-18 21:12:07
问题 I have been using the code below (which I have now added await to) to send files to S3. It has worked fine with my lambda code but as I move to transfer larger files like MP4 I feel I need async/await. How can I fully convert this to async/await? exports.handler = async (event, context, callback) => { ... // Copy data to a variable to enable write to S3 Bucket var result = response.audioContent; console.log('Result contents ', result); // Set S3 bucket details and put MP3 file into S3 bucket

Cannot load Rails.config.active_storage.service

不羁岁月 提交于 2021-02-18 20:49:19
问题 I'm setting up a new rails 5.2 app utilising Active Storage and using AWS for the hosting of images in production. However, I'm having an issue with the app reading the credentials: 2018-07-06T08:11:52.625415+00:00 app[web.1]: ! Unable to load application: Aws::Sigv4::Errors::MissingCredentialsError: Cannot load `Rails.config.active_storage.service`: 2018-07-06T08:11:52.625432+00:00 app[web.1]: missing credentials, provide credentials with one of the following options: 2018-07-06T08:11:52

Upload path based on a record value for Carrier wave Direct

江枫思渺然 提交于 2021-02-18 18:11:35
问题 I want to configure an upload path for Carrier wave Direct,which I am using to upload files directly to Amazon s3.In app/uploaders/myuploader.rb ,I have, def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end I want to modify this so that,the path looks like, "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{User.name}". so it will be some thing like, "uploads/Users/avatar/michael_jordan/.." Where User is the model in which the uploader is mounted. I have

How to display image from aws s3 in blade laravel 5.2

两盒软妹~` 提交于 2021-02-18 17:10:51
问题 I have created a method for getting the data(image file) from aws S3 like this : public static function getImage ($imagePath) { if(Storage::exists($imagePath)) { return Storage::disk('s3')->get($imagePath); }else { return 'No Image'; } } I'm sure that those image is exist on the aws, so there is no problem with that. And then I use above method as the src in my blade view like this : {!!Html::image(getImage($myPath),'logo',['width'=>60,'height'=>55])!!} $myPath here already point to the

Amazon Bucket Policy for only mobile app access

夙愿已清 提交于 2021-02-18 13:51:54
问题 I have a bucket in Amazon S3 and I set data inside read only for everyone. However, this is not what I want. I would like that data to be accessible only from my mobile application and restrict it to download by url. Is that possible? if so how to implement such bucket policy? 回答1: Traditionally, access to a mobile app is done this way: The mobile app user authenticates to your back-end (through your mobile app). This could be done with Amazon Cognito or with your own database of username

How can I use versioning in S3 with boto3?

假装没事ソ 提交于 2021-02-18 11:44:08
问题 I am using a versioned S3 bucket, with boto3. How can I retrieve all versions for a given key (or even all versions for all keys) ? I can do this: for os in b.objects.filter(Prefix=pref): print("os.key") but that gives me only the most recent version for each key. Many thanks, 回答1: import boto3 bucket = 'bucket name' key = 'key' s3 = boto3.resource('s3') versions = s3.Bucket(bucket).object_versions.filter(Prefix=key) for version in versions: obj = version.get() print(obj.get('VersionId'), obj

Download S3 Files with Boto

岁酱吖の 提交于 2021-02-18 11:42:05
问题 I am trying to set up an app where users can download their files stored in an S3 Bucket. I am able to set up my bucket, and get the correct file, but it won't download, giving me the this error: No such file or directory: 'media/user_1/imageName.jpg' Any idea why? This seems like a relatively easy problem, but I can't quite seem to get it. I can delete an image properly, so it is able to identify the correct image. Here's my views.py def download(request, project_id=None): conn =

Restricting file types on amazon s3 bucket with a policy

六眼飞鱼酱① 提交于 2021-02-18 10:11:34
问题 I'm trying to set up so the only file types the bucket can hold would be png, jpeg, and gif images. I'm trying to put in a bucket policy like this { "conditions": [ {"bucket": "bucketname"}, ["starts-with", "$Content-Type", "image/jpeg"], ["starts-with", "$Content-Type", "image/png"], ["starts-with", "$Content-Type", "image/gif"], ["content-length-range", 0, 10485760] ] } Then I'm also trying to limit the size but when I try to update my policy I get the error "Invalid policy element -

AWS S3 console: An unexpected error occurred

二次信任 提交于 2021-02-18 08:57:09
问题 I've made an account at aws, created a bucket and upload some files. I've set the bucket as an static web page and i can access to the files using the url, but now, when i get into the AWS console and into the S3 service i can't see my bucket, all I see is a message saying "An unexpected error occurred". Any suggestions? I've got no bills pendings. Thanks in advance! 回答1: I had the same problem, but after deactivating CORS plugin (on Chrome) it started to work again. 回答2: I confirm that

Does the ListBucket command guarantee the results are sorted by key?

半腔热情 提交于 2021-02-18 08:52:49
问题 When calling the S3 ListBucket command (via either REST or SOAP API), is the result set returned in any particular order? I would expect, given the nature of object keys and markers, that the result set is always sorted by object key. But I haven't seen any documentation confirming this. 回答1: Update : Amazon has changed their documentation as shown below. They are returned alphabetically . List results are always returned in UTF-8 binary order. See http://docs.aws.amazon.com/AmazonS3/latest