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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:54:38+00:00 2026-06-16T20:54:38+00:00

Can’t figure out how to do this? and couldn’t find much help from anywhere

  • 0

Can’t figure out how to do this? and couldn’t find much help from anywhere else!

I have set up the paperclip and fog like this;

config/initializers/fog.rb

     connection = Fog::Storage.new({
       :provider           => 'Rackspace',
       :rackspace_username => '',
       :rackspace_api_key  => ''
     })

environment.rb;

    Paperclip::Attachment.default_options.update({
    :path             => ":attachment/:id/:timestamp_:style.:extension",
    :storage          => :fog,
    :fog_credentials  => {
      :provider           => 'Rackspace',
      :rackspace_username => '',
      :rackspace_api_key  => '',
      :persistent         => false
    },
    :fog_directory    => '',
    :fog_public       => true

})

I am using file_field to get an image and then posting it to my controller. This gets me something like this in;

"pic"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007f90ac06a6c8 @original_filename="3245-1920x1200.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"cloth[pic][image]\"; filename=\"3245-1920x1200.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20130104-5386-103laem>>}

What I can’t understand is that how do I go about actually saving this file to cloud files using something like this;

file = directory.files.create(
  :key    => 'resume.html',
  :body   => File.open("/path/to/my/resume.html"),
  :public => true
)

EDIT

Relevant Models;

class Cloth
  include Mongoid::Document
  has_many :pics

class Pic
  include Mongoid::Document
  include Mongoid::Paperclip
    belongs_to :cloth

    has_mongoid_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }

And in the controller this is how I am currently creating pic based on above params;

@cloth = Cloth.new
@cloth.pics.create!(params[:cloth][:pic])
  • 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-16T20:54:39+00:00Added an answer on June 16, 2026 at 8:54 pm

    Let’s step back and look at the problem from different perspective. Can you see if the following script will upload an image to your container:

    require 'fog'
    service = Fog::Storage.new({
      :provider                 => 'Rackspace',
      :rackspace_username        => YOUR_USERNAME,
      :rackspace_api_key    => YOUR_API_KEY
      })
    
    container = service.directories.new(:key => YOUR_CONTAINER_NAME)
    container.files.create :key => 'my-pix.jpg', :body => File.open PATH_TO_FILE
    

    Update the uppercase parameters with the appropriate variables and let me know what happens. Hopefully this will help narrow down the problem.

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

Sidebar

Related Questions

Can anyone help me trying to find out why this doesn't work. The brushes
Can any one help me in sorting this out in sed/awk/perl Input file Start
Can find why i get this error can someone help? package Android.data; public class
Can someone help me figure out why my logo image isn't resizing according the
Can someone please help me find the memory leak which is occurring here? I
Does anyone know how can I replace this 2 symbol below from the string
Can you have submenus with the top level set to checkable in WPF? I
Can't get over it, no matter how much I search. I have AlarmManager, where
Can I order my users in the database, so I don't have to say
Can I change the field public virtual ClassOne ClassOne { get; set; } to

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.