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 6054267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:08:02+00:00 2026-05-23T08:08:02+00:00

I have this working locally, storing the template files in #{Rails.root}/tmp , using system

  • 0

I have this working locally, storing the template files in #{Rails.root}/tmp, using system "cd tmp/template; zip -r ../#{@filename} *" to zip up the files, sending the .docx (zip archive) to S3 and then to the browser. The problem is that Heroku is not finding the files. Before I create the xml file, I am copying the template directory from another location (system "cp -R support/ser_template tmp/"). I understand Heroku’s read-only filesystem but I can’t have #{Process.pid}‘s littering my filenames (Word requires the xml file to be named document.xml).

Is there anyway I can store the template files on Amazon and still use Heroku’s system zip utility? RubyZip does not create proper docx archives.

Edit: here is the code:

require 'aws/s3'

class WordDocument
  include ConnectS3

  def initialize(content)
    connect_s3
    @pid = Process.pid
    @filename = "SER_" + Time.now.strftime("%Y%m%d-%H%M%S") + '.docx'
    system "cp -R #{Rails.root}/support/ser_template #{temp_path}"
    xml = File.open(xml_path, 'w')
    xml.puts content
    xml.close
    system "cd #{temp_path}; zip -r #{@filename} *"
    docx = File.open(temp_path + "/" + @filename, 'r')
    AWS::S3::S3Object.store(s3_path, docx, @s3_credentials["bucket"], :use_virtual_directories => true)
    AWS::S3::S3Object.grant_torrent_access_to s3_path, @s3_credentials["bucket"]
  end

  def temp_path
    "#{Rails.root}/tmp/#{@pid}_ser"
  end

  def xml_path
    temp_path + "/word/document.xml"
  end

  def path
    "https://s3.amazonaws.com/" + @s3_credentials["bucket"] + s3_path
  end

  def s3_path
    '/section_editor_reports/' + @filename
  end
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-23T08:08:02+00:00Added an answer on May 23, 2026 at 8:08 am

    Can’t you just a create directory within #{Rails.root}/tmp called, say, #{Process.pid}_docx/something_nice/? Copy (or symlink) what you need into:

    #{Rails.root}/tmp/#{Process.pid}_docx/something_nice/
    

    Then

    system "cd #{Rails.root}/tmp/#{Process.pid}_docx/; zip -r x.zip something_nice"
    

    And then you have:

    #{Rails.root}/tmp/#{Process.pid}_docx/x.zip
    

    With a nice pretty internal structure that doesn’t include your PID.

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

Sidebar

Related Questions

Using: Rails 3.0.3 Friendly_id: 4.0.0.beta11 I have create a fully working development version of
I have this working definition: IDENTIFIER [a-zA-Z][a-zA-Z0-9]* I don't want to keep repeating the
I have this working great, but I'd like a deeper understanding of what is
I currently have this working but it requires me to have a static method
I have this regex working but now need to allow numbers without the decimal
I have this query working but it is not returning back exactly what I
I have this thing working mostly. What I don't get is, if I have
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
As a beginner in Ocaml, I have this current working code: ... let ch_in
i have this <li><a href=# >title</a> <span style='text-align:right;'>(0)</span></li> its not working and this <li><a

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.