Skip to content

Commit

Permalink
add cleaned_filename replacement variable for key
Browse files Browse the repository at this point in the history
  • Loading branch information
ncri committed Oct 19, 2014
1 parent 47de8f5 commit 63719d1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/assets/javascripts/s3_direct_upload.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ $.fn.S3Uploader = (options) ->
name: "content-type"
value: fileType

filename = @files[0].name.replace(/\.[^/.]+$/, '')
key = $uploadForm.data("key")
.replace('{timestamp}', new Date().getTime())
.replace('{unique_id}', @files[0].unique_id)
.replace('{cleaned_filename}', filename.replace(/\s/g, '_').replace(/[^\w.-]/gi, ''))
.replace('{extension}', @files[0].name.split('.').pop())

# substitute upload timestamp and unique_id into key
Expand Down

0 comments on commit 63719d1

Please sign in to comment.