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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:55:19+00:00 2026-06-06T21:55:19+00:00

Im writing an app to store files on Amazon S3. Im pretty close, Im

  • 0

Im writing an app to store files on Amazon S3. Im pretty close, Im able to save and retrieve files using a url. However since these links are public Im trying to use the following method in my assetscontroller to retrieve stored files from S3.

As links these files can be viewed/accessed in the browser, but if I use this code :

#This action will let the users download the files (after a simple authorization check)
def get
  asset = current_user.assets.find_by_id(params[:id])
  if asset
  #Parse the URL for special characters first before downloading  
  data = open("#{URI.parse(URI.encode(asset.uploaded_file.url))}")
  #then again, use the "send_data" method to send the above binary "data" as file.  
   send_data data, :filename => asset.uploaded_file_file_name 

 else
   flash[:error]="Access Violation"
   redirect_to assets_path
 end

end

Im getting this error in my browser:

Errno::ENOENT in AssetsController#get
No such file or directory - http://s3.amazonaws.com/BUCKETNAME/assets/29/FILENAME.jpeg?    1339979591

When I click on the resource on the S3 site as Im logged into the S3 management console, the file is shown in my browser and its link is

https://s3.amazonaws.com/BUCKETNAME/assets/29/FILENAME.jpeg?     AWSAccessKeyId=XXXXXXXXXXXExpires=1340003832&Signature=XXXXXXXXXXXXXXXXXX-amz-security-      token=XXXXXXXXX//////////XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

So it does exist but cant be accessed through my app

Here is my Application Trace from my browser:

app/controllers/assets_controller.rb:99:in `initialize'
app/controllers/assets_controller.rb:99:in `open'
app/controllers/assets_controller.rb:99:in `get'

Any clues on whats going on?

Thanks

  • 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-06T21:55:21+00:00Added an answer on June 6, 2026 at 9:55 pm

    You can also just redirect the user to the file on S3.

    Just try

    redirect_to asset.uploaded_file.url
    

    instead of send_file. send_file expects a path to a local file, which is then used by the webserver.

    If you’ve set s3_permissions => :private, then you need to call

    redirect_to asset.uploaded_file.expiring_url(10)
    

    It’s also interesting that in your error message it is http against https in s3 – you can also try to add the following option to your model’s has_attached_file

    :s3_protocol => 'https' 
    

    Hope this helps.

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

Sidebar

Related Questions

I'm writing a web app for the iPad ( not a regular App Store
I am writing a Windows Store App toy application for Windows 8. It has
I'm writing a Rails app that needs to store shape data representing the floor
I am writing an app to connect to a third party application using REST
I am writing an app where I want the customer to be able to
I want to use a file to store purchased data. Since the app is
I am (re)writing an android app that uses an SQLite database to store various
I am writing a native iPhone and Android app using Sencha Touch inside Phonegap
In my app, i want to download video files from server and store that
I'm writing a simple J2ME phone app and I want to save the status

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.