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

  • SEARCH
  • Home
  • 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 3949042
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:26:48+00:00 2026-05-20T01:26:48+00:00

My user uploads a zip file with 3 files (A.ttf, A.svg, A.otf) and I

  • 0

My user uploads a zip file with 3 files (A.ttf, A.svg, A.otf) and I want to store the original zip plus the 3 font files inside it. I’ve created the 3 versions with this code

version :ttf
    process :font => :ttf
end

version :svg
    process :font => :svg
end

version :otf
    process :font => :otf
end

It successfully saves 4 copies of the original file, all with the proper file name. However, I don’t know how to get CarrierWave to store the individual files. This code doesn’t work. 🙁

def font(format)
  new_file = nil

  # Loop through the zip file and extract the files
  Zip::ZipFile.open(@file.file) do |files|
    files.each do |f|
      next unless f.file?

      filename  = f.name.split("/").last
      ext       = filename.split('.').last

      # Save the file with the proper file extension
      new_file = f if ext == format
  end

  # Return the file to be stored by CarrierWave
  new_file
end
  • 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-20T01:26:48+00:00Added an answer on May 20, 2026 at 1:26 am

    OK, after many hours of banging my head against the wall the light finally came on. The solution is in how CarrierWave processes the upload. When you define a version, CW duplicates the file with a new name ([version name]_original_filename) and gives it to you in the current_path variable. You can do anything you want with this file reference (ie open the file and truncate it, or fill it with random date, etc.) and when you get done CW will store the file for you.

    Somehow I missed the connection and when I realized what was going on it almost blinded me. I’m answering this question here so that it might help some other poor soul lost in the dark. And to show the world my ignorance. :/

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

Sidebar

Related Questions

I want to upload a zip file in a jsp page and the user
A user uploads a large file to my website and I want to gzip
If the user uploads some file to my server and I want to make
I have a form where the user can upload a zip file, it works
On my site a user may upload a file (pic, zip, audio, video, whatever).
I made an upload system where the user uploads a file and that file
I'm working on a web application where a user uploads a list of files,
I have a very simple page with which a user uploads a file. Using
An app uses paperclip to handle file uploads for user avatars. Paperclip currently deletes
I'm writing a web application where the user upload a zip file that contains

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.