Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3599396
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:21:45+00:00 2026-05-18T20:21:45+00:00

This is an odd question, but only commensurate with the strange behavior I’m seeing.

  • 0

This is an odd question, but only commensurate with the strange behavior I’m seeing. My app is Rails 3/Paperclip/S3.

Symptoms:

  • All images are uploading regardless of their title.
  • When uploading a .pdf or .doc, if the title has no spaces like my_doc.pdf, it uploads fine.
  • When uploading a .pdf or .doc with spaces, such as My Doc.pdf, it fails, either with error broken pipe or by the file silently failing to upload to S3.
  • When uploading a .pdf or .doc with numbers, such as mydoc20.pdf, it also fails as above.

I imagine there are two possible solutions to this problem.

  1. Fix the broken pipe error directly (preferred method).
  2. Automatically rename every uploaded file to remove spaces and numbers before it is saved to S3 – while not fixing it at the source, I imagine this would allay the issue.

I would greatly appreciate any help you can give me in fixing 1 and/or 2.


Code

# Upload.rb model
class Upload < ActiveRecord::Base
  has_attached_file :document,
    :storage => :s3,
    :s3_credentials => "#{::Rails.root.to_s}/config/s3.yml",
    :path => "/docs/:style/:id/:basename.:extension"
  has_attached_file :photo,
    :styles => {:medium => "200x300>", :thumb => "100x150>" },
    :storage => :s3,
    :s3_credentials => "#{::Rails.root.to_s}/config/s3.yml",
    :path => "/photos/:style/:id/:basename.:extension"

# s3.yml
development:
  bucket: dev_bucket_name
  access_key_id: dev_acc_key
  secret_access_key: dev_sec_key
production:
  bucket: my_production_bucket
  access_key_id: my_access_key_id
  secret_access_key: my_secret_key

# environment.rb is empty with regard to uploading.

# uploads_controller.rb
def edit
  @candidate = Candidate.find(current_user.user_type_id)
  render :layout => 'forms'
end

def update
  @candidate = Candidate.find(params[:id])
  if @candidate.update_attributes(params[:candidate])
    flash[:notice] = "Profile updated successfully."
    redirect_to :action => "show", :id => params[:id]
  else
    flash[:notice] = "There was an error updating your profile."
    render :action => "edit", :id => params[:id]
  end
end

I don’t believe there are any methods involved. I almost hope there is something obviously wrong with my approach because that means it’ll get fixed :).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:21:46+00:00Added an answer on May 18, 2026 at 8:21 pm

    For part two this should do it:

    @s = "Really Important!*() Document version#123123.newest.pdf"
    @s.gsub!(' ','_').downcase! #this will make everything lowercase and replace all spaces with underscores
    @s.gsub!(/[^a-zA-Z._]+/,'') #this will remove all numbers and special characters except . and _
    puts @s #prints "really_important_document_version.newest.pdf"
    

    Edit: After some more research into paperclip I found the following: http://blog.wyeworks.com/2009/7/13/paperclip-file-rename

    Check that link out, I believe it is what you are looking for.

    Edit 2: In my initial read of your post I missed the part about pulling out numbers as well, I have modified the regulat expression code to account for that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an odd question, but only commensurate with the strange behavior I'm seeing.
This might sound a bit of an odd question but I know what I
I guess this is kind of an odd question but I have tried setting
This might be an odd question, but when I scale my image in C#
This will be probable quite odd question. But i thought I will give it
This might be a little bit odd question, but Im trying to figure out
An odd question this will be, but here goes. I have a page on
This may seem like an odd question, but I have my own reasons for
(Please note that the behavior described in this question only appeared because of something
Well, maybe a odd question, but how would I handle unhandled exceptions only from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.