FIX: support for underscores in URLs (when using S3 storage)

This commit is contained in:
Régis Hanol 2014-11-12 17:08:11 +01:00
parent a8a0be0b34
commit 7244266174
4 changed files with 17 additions and 1 deletions

View file

@ -249,6 +249,10 @@ gem 'stringex', require: false
gem 'logster' gem 'logster'
# we need that to support underscore in URLs (mostly when using S3 for storing files)
# cf. http://stackoverflow.com/a/17108137/11983
gem 'addressable'
# perftools only works on 1.9 atm # perftools only works on 1.9 atm
group :profile do group :profile do
# travis refuses to install this, instead of fuffing, just avoid it for now # travis refuses to install this, instead of fuffing, just avoid it for now

View file

@ -407,6 +407,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
actionpack-action_caching actionpack-action_caching
active_model_serializers (~> 0.8.0) active_model_serializers (~> 0.8.0)
addressable
annotate annotate
barber barber
better_errors better_errors

View file

@ -847,7 +847,7 @@ en:
purge_inactive_users_grace_period_days: "Grace period (in days) before a user who has not activated their account is deleted." purge_inactive_users_grace_period_days: "Grace period (in days) before a user who has not activated their account is deleted."
enable_s3_uploads: "Place uploads on Amazon S3 storage. IMPORTANT: requires valid S3 credentials (both access key id & secret access key)." enable_s3_uploads: "Place uploads on Amazon S3 storage. IMPORTANT: requires valid S3 credentials (both access key id & secret access key)."
s3_use_iam_profile: 'Use AWS EC2 IAM role to retrieve keys. NOTE: enabling will override "s3 access key id" and "s3 secret access key" settings.' s3_use_iam_profile: 'Use AWS EC2 IAM role to retrieve keys. NOTE: enabling will override "s3 access key id" and "s3 secret access key" settings.'
s3_upload_bucket: "The Amazon S3 bucket name that files will be uploaded into. WARNING: must be lowercase, no periods." s3_upload_bucket: "The Amazon S3 bucket name that files will be uploaded into. WARNING: must be lowercase, no periods, no underscores."
s3_access_key_id: "The Amazon S3 access key id that will be used to upload images." s3_access_key_id: "The Amazon S3 access key id that will be used to upload images."
s3_secret_access_key: "The Amazon S3 secret access key that will be used to upload images." s3_secret_access_key: "The Amazon S3 secret access key that will be used to upload images."
s3_region: "The Amazon S3 region name that will be used to upload images." s3_region: "The Amazon S3 region name that will be used to upload images."

View file

@ -1,4 +1,15 @@
require "open-uri" require "open-uri"
require "addressable/uri"
class URI::Parser
# HACK to support underscores in URLs
def split(url)
a = Addressable::URI::parse(url)
[a.scheme, a.userinfo, a.host, a.port, nil, a.path, nil, a.query, a.fragment]
end
end
class FileHelper class FileHelper