batter / s3_cors_fileupload

A gem for Rails to allow for uploading of files to AWS-S3 via CORS using the jQuery-File-Upload
MIT License
21 stars 9 forks source link

Meaningful errors when config options are missing #4

Closed mguterl closed 10 years ago

mguterl commented 10 years ago

I was receiving the following error when accessing /source_files and it took me a few minutes to realize I was missing some configuration options.

no implicit conversion of nil into String

s3_cors_fileupload (0.3.0) lib/s3_cors_fileupload/rails/policy_helper.rb:44:in `digest'
s3_cors_fileupload (0.3.0) lib/s3_cors_fileupload/rails/policy_helper.rb:44:in `upload_signature'
s3_cors_fileupload (0.3.0) lib/s3_cors_fileupload/rails/form_helper.rb:30:in `s3_cors_fileupload_form_tag'
app/views/s3_uploads/index.html.haml:5:in `_app_views_s__uploads_index_html_haml__634519600383552528_70251462003260'

This pull request does some assertions to ensure that the configuration options are set prior to calculating the upload signature. A better solution might validate this information when the yaml file is read, but it seems like that was a much larger change to put in place.

batter commented 10 years ago

Thanks for the PR. I think the config file makes it pretty explanatory which options need to be set but it doesn't hurt to have a meaningful error message like this available. I cleaned up the code a bit before merging, hope you approve. Cheers!