aws-sdk-ruby

File encoding issue when downloading file from AWS S3

房东的猫 提交于 2019-12-24 06:21:18
问题 I have a CSV file in AWS S3 that I'm trying to open in a local temp file. This is the code: s3 = Aws::S3::Resource.new bucket = s3.bucket({bucket name}) obj = bucket.object({object key}) temp = Tempfile.new('temp.csv') obj.get(response_target: temp) It pulls the file from AWS and loads it in a new temp file called 'temp.csv'. For some files, the obj.get(..) line throws the following error: WARN: Encoding::UndefinedConversionError: "\xEF" from ASCII-8BIT to UTF-8 WARN: /Users/.rbenv/versions/2

How do I mock AWS SDK (v2) with rspec?

时光毁灭记忆、已成空白 提交于 2019-12-21 05:56:49
问题 I have a class which reads/processes messages from an SQS queue using the aws-sdk-rails gem (which is a wrapper on aws-sdk-ruby v2). How do I mock the AWS calls so I can test my code without hitting the external services? communicator.rb : class Communicator def consume_messages sqs_client = Aws::SQS::Client.new # consume messages until the queue is empty loop do r = sqs_client.receive_message({ queue_url: "https://sqs.region.amazonaws.com/xxxxxxxxxxxx/foo", visibility_timeout: 1, max_number

Error “uninitialized constant AWS (NameError)”

微笑、不失礼 提交于 2019-12-20 15:58:42
问题 It is saying AWS is uninitialized. I am usign the aws-sdk-core gem. I tried using the aws-sdk gem instead, and the problem was still there. This is the initializers/aws.rb file: AWS.config(:access_key_id => ENV['AWS_ACCESS_KEY_ID'], :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']) s3 = AWS::S3.new AVATAR_BUCKET = s3.buckets[ENV['AVATAR_BUCKET_NAME']] When I try running the server or opening the console I get this error: /initializers/aws.rb:1:in `': uninitialized constant AWS (NameError)

Error “uninitialized constant AWS (NameError)”

。_饼干妹妹 提交于 2019-12-20 15:58:09
问题 It is saying AWS is uninitialized. I am usign the aws-sdk-core gem. I tried using the aws-sdk gem instead, and the problem was still there. This is the initializers/aws.rb file: AWS.config(:access_key_id => ENV['AWS_ACCESS_KEY_ID'], :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']) s3 = AWS::S3.new AVATAR_BUCKET = s3.buckets[ENV['AVATAR_BUCKET_NAME']] When I try running the server or opening the console I get this error: /initializers/aws.rb:1:in `': uninitialized constant AWS (NameError)

Rails Active storage Unable to autoload constant ActiveStorage::Blob::Analyzable

坚强是说给别人听的谎言 提交于 2019-12-08 03:12:47
问题 I've updated rails from 5.1.4 to 5.2 and remove Papaerclip to use Active Storage. I'm using digitalocean spaces. In my development env I've setted credentials in storage.yml to save images to digitalocean. I've added aws-sdk-s3 gem in gemfile (without version, may be this the problem?). I run db:migrate for active storage. But when I'm going to submit the form with an image upload html tag, i receive this error: Unable to autoload constant ActiveStorage::Blob::Analyzable. Anyone can help me?

Recommended way to generate a presigned url to S3 Bucket in Ruby

怎甘沉沦 提交于 2019-12-05 23:57:50
问题 I am trying to generate a pre-signed url on my Rails server to send to the browser, so that the browser can upload to S3. It seems like aws-sdk-s3 is the gem to use going forward. But unfortunately, I haven't come across documentation for the gem that would provide clarity. There seem to be a few different ways of doing so, and would appreciate any guidance on the difference in the following methods - Using Aws::S3::Presigner.new (https://github.com/aws/aws-sdk-ruby/blob/master/aws-sdk-core

Recommended way to generate a presigned url to S3 Bucket in Ruby

大兔子大兔子 提交于 2019-12-04 06:21:07
I am trying to generate a pre-signed url on my Rails server to send to the browser, so that the browser can upload to S3. It seems like aws-sdk-s3 is the gem to use going forward. But unfortunately, I haven't come across documentation for the gem that would provide clarity. There seem to be a few different ways of doing so, and would appreciate any guidance on the difference in the following methods - Using Aws::S3::Presigner.new ( https://github.com/aws/aws-sdk-ruby/blob/master/aws-sdk-core/lib/aws-sdk-core/s3/presigner.rb ) but it doesn't seem to take in an object parameter or auth