Do not resolve url in tests with Webmock and CarrierWave remote upload - ruby-on-rails

CarrierWave has a nice feature for uploading images from remote locations https://github.com/carrierwaveuploader/carrierwave#uploading-files-from-a-remote-location
I'm using Webmock to stub remote requests, but they don't play nicely together. I guess it's because CarrierWave way of downloading images is quite unique.
The problem is that CarrierWave resolves host and I can't stub it because of that.

Related

How to speed up image uploading carrierwave and Rails4

I am working with Rails4 and carrierwave, uploading the images and files to S3. But it's taking much time and very slow. How to handle this situation to speed up the server speed!!!
How to handle this using Background Jobs and Handle request from lot of users.
Also getting images is very slow into my application!!!
Can you suggest me how to achieve Rails severe works fast while uploading files?
You might consider uploading directly from the client to S3 via Ajax. This would nearly completely take your server out of the mix.
Uploading Image to Amazon s3 with HTML, javascript & jQuery with Ajax Request (No PHP)
This is a well documented concept elsewhere online.
Amazon S3 now has notifications for newly created objects.
http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
You could drop the upload notifications into an Amazon SQS queue. You could then use a gem like Fog to create a background worker to pull events off the queue to create or update records in the database to reflect the newly completed upload.
https://github.com/fog/fog
Regardless of the solution, if you're uploading big files, it's likely your local network's upload speed that is the bottleneck.

How to save dragonfly attachment directly to s3 without hitting the rails server?

I have setup-ed my rails application to use dragonfly + s3. Everything works fine up till here. and i have deployed my rails application on Heroku. Now i want to upload my images to s3 without hitting the rails server, as due to heavy uploading my rails server crashes. I want some way to insert Redis into picture so that images are queued to Redis and sidekiq or Resque will process them in background.My question is what should be the approach to do such thing. Is there any ruby library exists to achieve this.Any help is appreciated.

Caching Paperclip asset URLs to avoid network request when getting generated URL?

Is there an acceptable way to have Paperclip not make a network request each time you call model.attachment.url()?
I'd like to cache the URLs for faster load speeds / being able to load my development environment, without needing connected wifi, etc.
If you are using the fog provider, it appears that you should be able use Paperclip::Attachment.default_options[:fog_host] = "http://myhost.com" in your paperclip initializer to specify your host. This should reduce the look up calls.

Thumbnails with carrierwave_direct or s3_direct_upload

Is it possible to generate thumbnails using carrierwave_direct or s3_direct_upload uploading an image direct to amazon s3? I'm with a problem and didn't found the best solution for me yet. I need image thumbnails, my amazon server has a timeout and I can't send large files to my application and sending directly I did not found any way to make thumbs. I'm thinking about limit the image size before upload, have I any other options?

Carrierwave, Fog and URL Rewriting

I'm storing images in Amazon S3 using Fog and Carrierwave. It returns a url like bucket.s3.amazonaws.com/my_image.jpg.
DNS entries have been set up so that images.mysite.com points to bucket.s3.amazonaws.com.
I want to adjust my views an APIs to use the images.mysite.com/my_image.jpg URL. Carrierwave, however, only spits out the Amazon based one. Is there a simple way to tell Carrierwave and/or Fog to use a different host for its URLs than normal? If not, how would I modify the uploader to spit it out?
Come to find out that, as of June 6th, 2012, Amazon AWS does not support custom SSL certs, which makes this a moot point.

Resources