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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:41:06+00:00 2026-06-14T06:41:06+00:00

I need to generate all my products from database table into the XML file.

  • 0

I need to generate all my products from database table into the XML file. Because my app run on Heroku, I need to use Amazon S3 as the storage.

Here’s an example of on how to save an image:

has_attached_file :photo,
       :styles => {
       :thumb=> "100x100#",
       :small  => "400x400>" },
     :storage => :s3,
     :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
     :path => "/:style/:id/:filename"

Which makes me a bit confused… because I am not sure about the logic of this task.
My idea is to run an action (say create_xml_feed) in the Products controller

 xml = Builder::XmlMarkup.new( :indent => 2 )
 xml.instruct! :xml, :encoding => "ASCII"
 xml.product do |p|
   p.name "Test"
 end

But here comes the problem – I don’t know, how to save the newly created file into Amazon S3 Bucket.

I’d be grateful for each advance, thank you

  • 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-06-14T06:41:07+00:00Added an answer on June 14, 2026 at 6:41 am

    First, create an active record class to hold your uploaded XML file. After this you can write the logic to create your xml string, create a new file by first creating a new instance of the XmlUploader class, then create the xml string you want, save it in a file and then assign this file as the attachment file. Once you save your xml file will be uploaded to s3.

    class XmlUploader < ActiveRecord::Base
      has_attached_file :uploaded_file, :storage => :s3,
      :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
      :path => "/:id/:filename"
    
      def create_uploaded_file
        xml = ::Builder::XmlMarkup.new( :indent => 2 )
        xml.instruct! :xml, :encoding => "ASCII"
        xml.product do |p|
          p.name "Test"
        end
        file_to_upload = File.open("some-file-name", "w")     
        file_to_upload.write(xml)
        file_to_upload.close()
        self.uploaded_file = File.open("some-file-name")
        self.save!
      end
    end
    
    class CreateXmlUploaders < ActiveRecord::Migration
      def change
        create_table :xml_uploaders do |t|
          t.attachment :uploaded_file
          t.timestamps
        end
      end
    end
    
    xml_file = XmlUploader.new
    xml_file.create_uploaded_file
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to generate Entities/Object from selected tables - not all. Is this possible
I have an html file and i need to generate a list of all
I need to generate all combinations (not permutations) in VB .NET, I've been search
I need to test a controller, of action index (generated by the grails generate-all
I need to generate a report where the user can choose All Issues, Open
I need generate action links outside controllers. I can use Html.Action in Views, Url.Action
I need to generate a couple of objects from lists in Javascript. In Python,
I need to generate css based on client queries. I use the @import url()
I'm trying to use JAXB to unmarshal this file into Java objects. I know
I have a page that generates a list of my products from a database.

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.