I signed up for Amazons S3 service.
I am having a problem with my Gallery script. It want the URL relative to the server where the files are located at?
So instead of http://gallery.s3.amazonaws.com/10/images
They want: /home/www/gallery.s3.amazonaws.com/10/images
The problem is I don't know what to use when it is Amazon s3?
Anybody have a solution?
Thanks.
I think you will need to specify what gallery software you are using. (Gallery 2, Gallery 3, Coppermine, Etc.) Or, are you writing your own script? If so, what language/platform?
Often, something expecting a physical path does not accept an HTTP URL unless HTTP support has been purposefully added.
Related
I built a rails app and set up s3 and paperclip together. So far, the images are being posted into my s3 account. But on the live app it's not actually showing the image and just showing the broken file icon.
Any ideas why this is happening? Is it a paperclip error? is it Heroku? Is it my controller?
Here's the live app: http://petaluma-marin.herokuapp.com/Nutrition-Recipes
Here's my repo: https://github.com/Gcamara14/Recipe_app
Thanks!!
Your url to the images is wrong. The URL for your second image currently is this
http://s3.amazonaws.com/recipe-app-gio/recipes/images/000/000/009/medium/Screen_Shot_2017-05-30_at_1.19.49_PM.png?1496243164
What it needs to be is this
http://s3-us-west-1.amazonaws.com/recipe-app-gio/recipes/images/000/000/009/medium/Screen_Shot_2017-05-30_at_1.19.49_PM.png?1496243164
Notice instead of http://s3.aws... at the beginning you need http://s3-us-west-1.aws...
Whenever I have issues with S3 I find it is easiest to go to the bucket and look at the path and then inspect the image or asset and see if they match.
To give you a hint about what the issue might be, in your browser if you copy/paste the url for a photo you should see this message:
The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
Take a look at your paperclip_defaults. You are missing the s3_host_name that would contain something like s3-us-west-1 (as mentioned in one of the prior answers).
Also looks like there is an issue already created in the paperclip repo that should help you out (here).
I've successfully uploaded, via Paperclip, images to the RackSpace cloudfile storage, and they appear correctly within subsequent webpages when I'm using the CDN url.
However, I can't figure out why Paperclip is not showing the files if I do not use CDN enabled cloud files.
Paperclip returns (via its 'url' method for the attachment) the more usual /attachments/fred/1/image/123.jpg path, however that results in a broken image as there is no actual file stored at that url - its in RS cloud file storage.
I'm not sure whether
a) Paperclip is supposed to give me a url to non-cdn location
b) Paperclip provides a url which results in it then responding at that url to provide the raw image data
c) Something completely different to a) and b)
If someone could please shed some light on what url I'm supposed to get back from Paperclip for non CDN enabled RackSpace stored files I think it would help steer me in the correct direction.
Thanks.
Rackspace Cloud Files has the ability to download files without a CDN, but after researching it paperclip and fog do not currently support this.
Paperclip supports both CDN access as well as downloading files using a temporary url (sans CDN). I was going to suggest using a temporary url, however, the get_http_url method paperclip uses to retrieve this url isn't currently implemented for Rackspace.
I have created a fog issue to address this https://github.com/fog/fog/issues/2103.
I'm experimenting with PaperClip and like it and it looks to be a good solution for our project. However, we'd like to store the uploaded files in another location on the server (ubuntu) besides the public folder and S3 is not an option. So 2 questions:
1) How to set the path and url to store uploads to another directory in ubunto besides the application root or,
2) How to perhaps store the uploaded files on another LAN server as well.
Thanks in advance to all who reply. After an exhaustive search I was surprised to only see Google results for developers only using either rails_root or S3 for storage in PaperClip. Also, if anyone recommends a better file uploading solution that will meet our needs than by all means please advise on that as well. Thanks again!
You can simply pass the :path option to has_attached_file to any path you desire. The docs talk about this, here: http://rdoc.info/gems/paperclip#Storage
If you mount some shared LAN storage on your web servers, then you can store them there. You do need a shared filesystem location available to all your app servers, so S3 is a common and easy to setup solution.
In my rails app I have used attachment_fu to upload images and stored it on s3.
I want to display these images on browser without retrieving it.
How can I display images by giving s3 path?
Thanks,
Jayashri
You just need to link to the correct S3 path for you images.
For public files they are in the format:
eg http://s3.amazonaws.com/[bucket]/[key]
If your content is private you'll need to create a signed url but all the SDKs and libraries make this easy.
Then use the url to display the images:
<img src="http://s3.amazonaws.com/mybucket/myfile.jpg" ... ></img>
It may help you to install the S3 organizer in Firefox so you can browser your directories. Then I believe the URL's are structured kinda like this...
http://BUCKET.s3.amazonaws.com/FOO/BAR.png
I'm writing a Rails application that serves files stored on a remote server to the end user.
In my case the files are stored on S3 but the user requests the file via the Rails-application (hiding the actual URL). If the file was on my servers local file-system, I could use the Apache header X-Sendfile to free up the Ruby process for other requests while Apache took over the task of sending the file to the client. But in my case - where the file is not on the local file-system, but on S3 - it seems that I'm forced to download it temporarily inside Rails before sending it to the client.
Isn't there a way for Apache to serve a "remote" file to the client that is not actually on the server it self. I don't mind if Apache has to download the file for this to work, as long as I don't have to tie up the Ruby process while it's going on.
Any suggestions?
Thomas, I have similar requirements/issues and I think I can answer your problem. First (and I'm not 100% sure you care for this part), hiding the S3 url is quite easy as Amazon allows you to point CNAMES to your bucket and use a custom URL instead of the amazon URL. To do that, you need to point your DNS to the correct amazon URL. When I set mine up it was similar to this: files.domain.com points to files.domain.com.s3.amazonaws.com. Then you need to create the bucket with the name of your custom URL (files.domain.com in this example). How to call that URL will be different depending on which gem you use, but a word of warning was that the attachment_fu plugin I was using was incorrectly sending me to files.domain.com/files.domain.com/name_of_file.... I couldn't find the setting to fix it, so a simple .sub method for the S3 portion of the plugin fixed it.
On to your other questions, to execute some rails code (like recording the hit in the db) before downloading you can simply do this:
def download
file = File.find(...
# code to record 'hit' to database
redirect_to 3Object.url_for(file.filename,
bucket,
:expires_in => 3.hours)
end
That code will still cause the file to be served by S3, but and still give you the ability to run some ruby. (Of course the above code won't work as is, you will need to point it to the correct file and bucket and my amazon keys are saved in a config file. The above is also using the syntax for the AWS::S3 gem - http://amazon.rubyforge.org/).
Second, the Content-Disposition: attachment issue is a bit more tricky. Hopefully, your situation is a bit more simple than mine and the following solution can work. Assuming the object 'file' (in this example) is the correct S3 object, you can set the disposition to attachment by
file.content_disposition = "attachment"
file.save
The above code can be executed after the file exists on the S3 server (unlike some other headers and permissions), which is nice and it can also be added when you upload the file (syntax depends on your plugin). I'm still trying to find a way to tell S3 to send it as an attachment and only when requested (not every time), and if you find that, please let me know your solution. I need to be able to sometimes download it and other times save embed images (for example) into HTML. I'm not using the above mentioned redirect but fortunately it seems that if you embed (such as a HTML image tag) a file with the content-disposition/attachment header, and the browser still displays the image normally (but I haven't throughly tested that across enough browsers to send it in the wild).
Hope that helps! Good luck.