Reputation: 46
Hitting quite the wall on this issue. Let me explain what i've done and show the snippets of configured code, to hopefully find a solution
Ruby: 2.4.0
Rails: 5.x
Gems (specific to this):
- carrierwave 1.2.3
- carrierwave-aws
Here is the error
NoMethodError - undefined method `match' for nil:NilClass:
app/controllers/api/v3/video_controller.rb:23:in `upload'
Here is my config/environments/carrierwave.rb file
CarrierWave.configure do |config|
config.storage :aws
config.aws_credentials = {
provider: "AWS",
aws_access_key_id: Rails.application.secrets.aws_access_id,
aws_secret_access_key: Rails.application.secrets.aws_access_secret,
region: "us-east-1"
}
config.aws_bucket = "{{BUCKET_NAME_HERE}}"
end
Here is my uploader
class VideoUploader < CarrierWave::Uploader::Base
storage :aws
end
Finally, here is how i'm calling the upload, since it's an API, i'm not using a form builder or model assignment.
def upload
video = params[:video]
if video
# Send file to Amazon S3 bucket and grab URL
uploader = VideoUploader.new
uploader.store!(video.tempfile)
# uploader.retrieve_from_store!(tempfile_name)
# logger.info uploader.download_url(video.original_filename)
end
end
I've tried carrierwave + fog, fog-aws. When I remove the S3 equation the file will be stored locally (development machine). I am at my wits end with trying lib/ hacks, downgrading versions. I hope its a simple oversight but am out of ideas.
Any help is greatly appreciated!
Upvotes: 0
Views: 406
Reputation: 46
Fixed! The problem was pretty stupid and man I wish I caught it sooner. The initializer file was in the environments directory (I even listed it in my question!), not the initializers directory... don't code on an empty stomach.
Would be great if the code could detect that missing file... but at least its solved.
Upvotes: 0