EzDevInfo.com

dragonfly

A Ruby gem for on-the-fly processing - suitable for image uploading in Rails, Sinatra and much more! Dragonfly

How do I save Dragonfly Images to a remote server using NGINX reverse proxy?

PROBLEM:

Images are not getting read/write to my DB server file structure for Dragonfly. I am able to interact with my database through active record for all of my Ruby models. All my static assets are working. User generated images should be saved as www.test.example.com/media/AgGdsgDGsdgsDGSGdsgsdg... on my remote server. However they are getting saved on whatever app server they get uploaded from.

BACKGROUND:

Ruby/Rails, Nginx, Passenger. We are moving from a single server solution to a 3 server solution. I have 2 app servers that sit behind a DB server. I am using Dragonfly Gem for user generated images and other content. On our current, single server setup, everything just points to localhost and works great.

10.102.66.4 is my lan IP for the DB server.

APP SERVERS NGINX.CONF:

user  pete;
...
http {
  passenger_pre_start http://example.com;
  passenger_pre_start http://example.com:3000;
  ...
  proxy_cache_path /home/pete/example/shared/tmp/dragonfly levels=2:2
  keys_zone=dragonfly:100m inactive=30d max_size=1g;
  ...
  server {
    listen      80;
    server_name example.com;
    rewrite     ^   https://example.com$request_uri? permanent;
  }

  server {
    listen 443 ssl default deferred;
    ssl on;
    ssl_certificate /etc/ssl/example.com.crt;
    ssl_certificate_key /etc/ssl/server.key;
    ssl_session_cache shared:SSL:1m;
    server_name example.com *.example.com;
    root /home/pete/example/current/public;
    passenger_enabled on;

    location /media {
      proxy_pass http://10.102.66.4:443;
      proxy_cache dragonfly;
      proxy_cache_valid      200  30d;
      break;
    }
  }
}

DB SERVER NGINX.CONF:

user pete;
...
http {
  sendfile on;
  ...
  keepalive_timeout 65;
  types_hash_max_size 2048;
  ...
  large_client_header_buffers 4 16k;

  server {
    listen 443 ssl;
    ssl_certificate /etc/ssl/example.com.crt;
    ssl_certificate_key /etc/ssl/server.key;

    location / {
      try_files $uri @app;
    }

    location @app {
      proxy_set_header host $Host;
      proxy_redirect off;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      root /home/pete/example/shared/;
    }
  }
}

DRAGONFLY.RB:

 require 'dragonfly'
 app = Dragonfly[:images]
 app.configure_with(:imagemagick)
 app.configure_with(:rails)

 if defined?(ActiveRecord::Base) 
   app.define_macro(ActiveRecord::Base, :image_accessor) 
   app.define_macro(ActiveRecord::Base, :file_accessor) 
 end

WHAT IVE TRIED:

'chown -R pete:pete /home/pete/example/current/public' and the permissions look correct.

Restarted server/nginx/ruby/etc...

Add 'large_client_header_buffers 4 16k;' to nginx.conf

ERRORS/LOGS:

CHROME CONSOLE:

 Failed to load resource: the server responded with a status of 400 (Bad Request)

NGINX ERROR.LOG (Yes.. I know it says 'warn')

 2015/06/25 11:49:11 [warn] 25591#0: *345 a client request body is buffered to a temporary file /var/lib/nginx/body/0000000002, client: 173.204.167.103, server: example.com, request: "POST /offices/1-big-o/users/1-peterb HTTP/1.1", host: "test.example.com", referrer: "https://test.example.com/offices/1-big-o/users/1-peterb/edit"

NGINX ACCESS.LOG:

 [25/Jun/2015:11:49:14 -0700] "GET /media/W1siZiIsIjIwMTUvMDYvMjUvMTFfNDlfMTFfNDcxXzhfYml0X21scF9vY19fX2xvY2tlX3R1bWJsZXJfYnlfbmlnaHRzaGFkZTQyNF9kNXppdmpmLmpwZyJdXQ HTTP/1.0" 400 681 "https://test.example.com/offices/1-big-o/users/1-peterb/edit" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.125 Safari/537.36

curl -k https://10.102.66.4:443

 <html>
 <head><title>403 Forbidden</title></head>
 <hr><center>nginx/1.4.6 (Ubuntu)</center>
 </body>
 </html>

UPDATE 1:

It seems that INSTEAD of saving my files on the DB server, it is saving them locally to my app server. The file structure is correct... Just wrong server.


Source: (StackOverflow)

possible to get POSTed parameters and RESPONSE content in Opera Dragonfly?

When I look at the Network tab in Opera Dragonfly, I'm not seeing POSTEd parameters or the RESPONSE content. Here's what I see:

 Raw Response
 HTTP/1.1 200 OK
 Server: Microsoft-IIS/5.1
 Date: Thu, 15 Jul 2010 12:43:19 GMT
 X-Powered-By: ASP.NET
 X-AspNet-Version: 2.0.50727
 Cache-Control: no-cache
 Pragma: no-cache
 Expires: -1
 Content-Type: text/html; charset=utf-8
 Content-Length: 22320

In Dragonfly, is there a way to examine the parameters posted to the server and the actual response from the server?


Source: (StackOverflow)

Advertisements

Trying to upload multiple files - Document(#70285786863740) expected, got ActionDispatch::Http::UploadedFile(#70285766684260) when

I'm trying to use Dragonfly to upload multiple files at a time and store them. I was able to successfully upload and store a single file by adding a document_uid and document_name to my case model, but now I want to create the ability to upload multiple files per case object so I need to have my document_uid and document_name in their own table with a FK to the case table.

I'm currently getting the error: Document(#70285786863740) expected, got ActionDispatch::Http::UploadedFile(#70285766684260)

app/models/case.rb

class Case < ActiveRecord::Base
  has_many :documents

  attr_accessible :documents
end

class Document < ActiveRecord::Base

    belongs_to :case
    dragonfly_accessor :document    # defines a reader/writer for an uploaded document

  attr_accessible :document_uid, :document_name
end

view

<%= form_for(@case) do |f| %> 
    ...
    <%= f.file_field :documents, :multiple => true %>
    ...
<% end %>

So far i just have the default create method in my controller

 # POST /cases
  # POST /cases.json
  def create
    @case = Case.new(params[:case])

    respond_to do |format|
      if @case.save
        format.html { redirect_to @case, notice: 'Case was successfully created.' }
        format.json { render json: @case, status: :created, location: @case }
      else
        format.html { render action: "new" }
        format.json { render json: @case.errors, status: :unprocessable_entity }
      end
    end
  end

params:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"KAsjoqrQT5HTNKsiH6bu3+MRKB0FKDLdP2Q/Gm9ZYdA=", "case"=>{"documents"=>[#<ActionDispatch::Http::UploadedFile:0x007fd95ebe97d8 @original_filename="Screen Shot 2014-01-25 at 8.59.17 PM.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"case[documents][]\"; filename=\"Screen Shot 2014-01-25 at 8.59.17 PM.png\"\r\nContent-Type: image/png\r\n", @tempfile=#<Tempfile:/var/folders/5w/tkmvdtbn2xn98hjy655s67tw0000gn/T/RackMultipart20140727-43998-1go1ez0>>, #<ActionDispatch::Http::UploadedFile:0x007fd95ebe9760 @original_filename="Screen Shot 2014-03-02 at 8.38.22 AM.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"case[documents][]\"; filename=\"Screen Shot 2014-03-02 at 8.38.22 AM.png\"\r\nContent-Type: image/png\r\n", @tempfile=#<Tempfile:/var/folders/5w/tkmvdtbn2xn98hjy655s67tw0000gn/T/RackMultipart20140727-43998-1kefqe0>>]}, "button"=>""}

What is causing this error and how can I circumvent it?


Source: (StackOverflow)

Multilevel inheritance in forms with photos Ruby on rails

I've a registration form, where photos are being uploaded through albums. It doesn't give me any error, it just doesn't insert anything into Photos. The rest of the form is executed well. Using dragonfly for photos proccesing, but it's not the problem I think...

Thank you!

Models:

profile.rb

class Profile < ActiveRecord::Base
has_many :albums
has_many :photos, :through => :albums
has_many :avatars

accepts_nested_attributes_for :albums
accepts_nested_attributes_for :avatars
end

album.rb

class Album < ActiveRecord::Base
belongs_to :profile
has_many :photos

accepts_nested_attributes_for :photos
end

photo.rb

class Photo < ActiveRecord::Base
belongs_to :profile
belongs_to :album


extend Dragonfly::Model
dragonfly_accessor :image
end    

Controllers:

models_controller.rb

def new
  @profile = Profile.new
  @profile.albums.build.photos.build
  @profile.avatars.build
end
def profile_params
params.require(:profile).permit(:name, :surname, :country, :town, :email, :year_of_birth, albums_attributes: [:id, :name, :profile_id, photos_attributes: [:id, :profile_id, :image]], avatars_attributes: [:id, :profile_id, :image])
 end

VIEWS:

<%= form_for @profile, :html => { :multipart => true } do |f| %>

      /...some fields are here ..../

     <%= f.fields_for :albums do |ff| %>
         <%= ff.text_area :name, :placeholder => "Name first album." %>

             <%= ff.fields_for :photos do |fff| %>
                 <%= fff.file_field :image, multiple: true, name: 'album[photos_attributes][][image]' %>

             <% end %>
     <% end %>
     <%= f.submit "Odeslat" %>
<% end %>               

Source: (StackOverflow)

Python speech recognition 'module' object has no attribute 'VARIANT'

I'm trying to get started using speech recognition in python. First I tried PySpeech (https://code.google.com/p/pyspeech/) using this code:

def listen():
    while 1:
        said = speech.input()
        print said
        if said == "off":
            break

and got the following traceback:

Traceback (most recent call last):
  File "C:/Users/REDACTED/Documents/Python Projects/listen.py", line 59, in <module> useful.listen()

  File "C:/Users/REDACTED/Documents/Python Projects/listen.py", line 48, in listen 
said = speech.input()

  File "C:\Python27\lib\site-packages\speech.py", line 162, in input
    listener = listenforanything(response)

  File "C:\Python27\lib\site-packages\speech.py", line 193, in listenforanything
    return _startlistening(None, callback)

  File "C:\Python27\lib\site-packages\speech.py", line 223, in _startlistening
    grammar = context.CreateGrammar()

  File "C:\Users\REDACTED\AppData\Local\Temp\gen_py\2.7\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x4.py", line 2298, in CreateGrammar
ret = self._oleobj_.InvokeTypes(14, LCID, 1, (9, 0), ((12, 49),),GrammarId

AttributeError: 'module' object has no attribute 'VARIANT'

Then I tried dragonfly per the suggestion at the top of the GoogleCode page for PySpeech using the following example code commonly found on dragonfly docs:

from dragonfly.all import Grammar, CompoundRule

# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
   spec = "do something computer"                  # Spoken form of command.
   def _process_recognition(self, node, extras):   # Callback when command is spoken.
       print "Voice command spoken."

# Create a grammar which contains and loads the command rule.
grammar = Grammar("example grammar")                # Create a grammar to contain the command        rule.
grammar.add_rule(ExampleRule())                     # Add the command rule to the grammar.
grammar.load()                                      # Load the grammar.

and got this very similar traceback:

Traceback (most recent call last):

  File "C:/Users/REDACTED/Documents/Python Projects/listen.py", line 14, in <module>
    grammar.load()                                      # Load the grammar.

  File "C:\Python27\lib\site-packages\dragonfly\grammar\grammar_base.py", line 302, in load
    self._engine.load_grammar(self)

  File "C:\Python27\lib\site-packages\dragonfly\engines\engine_sapi5.py", line 79, in load_grammar
    handle = self._compiler.compile_grammar(grammar, context)

  File "C:\Python27\lib\site-packages\dragonfly\engines\compiler_sapi5.py", line 68, in compile_grammar
    grammar_handle = context.CreateGrammar()

  File "C:\Users\REDACTED\AppData\Local\Temp\gen_py\2.7\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x4.py", line 2298, in CreateGrammar
    ret = self._oleobj_.InvokeTypes(14, LCID, 1, (9, 0), ((12, 49),),GrammarId

AttributeError: 'module' object has no attribute 'VARIANT'

Both modules were installed using PIP and run using python 2.7 interpreter. It seems like a python version issue to me given that the same error is thrown for two different modules implementing the same thing but I'm pretty stuck on how to proceed.

Any help is greatly appreciated and I'm happy to provide more code/info as its requested. Thanks!

EDIT 1: For anyone experiencing a similar problem who happens to stumble across this post, try https://pypi.python.org/pypi/SpeechRecognition/ as an alternative on py2.7. If it runs without error but behaves inconsistently or infinite loops, try modifying the init method of the recognizer class in init.py around line 100. The energy threshold required some tinkering for me (100->300) which is likely due to the specifics of your mic setup. I also increased my quiet duration (0.5->0.7) because it would cut me off sometimes. After these changes it works fairly well for me, returning very accurate text of the input speech in ~2 seconds after capture ends.


Source: (StackOverflow)

Extending Refinery cms Images

Model::

class Refphoto < Refinery::Core::BaseModel
  self.table_name = 'refinery_images'
  attr_accessible :image_name, :image_uid
end 

Console ::

Refphoto.first.image.thumb('320x240').url

I managed url's at development environment by using Refphoto.first.image_uid , while i changed to production (images are not displaying) with error below

Started GET "/system/refinery/images/2014/11/10/14_47_31_242_kids_magic_show_brisbane.jpg" for 127.0.0.1 at 2014-12-18 14:35:30 +0530
Processing by Refinery::PagesController#show as JPEG
  Parameters: {"path"=>"system/refinery/images/2014/11/10/14_47_31_242_kids_magic_show_brisbane", "locale"=>:en}
  Rendered /home/sid/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/refinerycms-core-2.1.3/app/views/refinery/_content_page.html.erb (13.9ms)
  Rendered refinery/pages/show.html.erb within layouts/application (22.2ms)
  Rendered /home/sid/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/refinerycms-core-2.1.3/app/views/refinery/_html_tag.html.erb (0.5ms)
  Rendered /home/sid/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/refinerycms-core-2.1.3/app/views/refinery/_site_bar.html.erb (2035.8ms)
  Rendered /home/sid/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/refinerycms-core-2.1.3/app/views/refinery/_google_analytics.html.erb (0.9ms)
  Rendered /home/sid/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/refinerycms-core-2.1.3/app/views/refinery/_head.html.erb (26.6ms)
  Rendered /home/sid/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/refinerycms-core-2.1.3/app/views/refinery/_header.html.erb (42.9ms)
  Rendered refinery/_footer.html.erb (0.7ms)
  Rendered /home/sid/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/refinerycms-core-2.1.3/app/views/refinery/_javascripts.html.erb (1.0ms)
Filter chain halted as :find_page rendered or redirected
Completed 404 Not Found in 2369.5ms (Views: 2244.6ms | ActiveRecord: 61.6ms)

I'll be thankful if anyone suggest how to get dragonfly url by using image path. This is the only reference i got left .


Source: (StackOverflow)

How to migrate data between datastores using Dragonfly

Is it possible to migrate data between two different datastores using Dragonfly?

I'm currently storing images in the DB - using a custom relational data store, and want to migrate to an S3-like web API sore.


Source: (StackOverflow)

Ruby on Rails, Apache, Passenger error 500 when try to upload images in production

I have an ubuntu server with apache (2.4.7) + passenger (5.0.0.beta2) + rails (4.2.0) + dragonfly (1.0.7)

The site is running OK, but when I upload images its when the server sends a 500 error. Sometimes allows me to upload one image and the second one sends a 500, sometimes the error appears when I try to upload the third image. (the size of the images are around the 100KB and the 700KB)

In the production.log there is no error. But in the apache error.log I have a lot of information but nothing that can help me, maybe one of you could understand the log:

[ pid=25856, timestamp=1422360930 ] Process aborted! signo=SIGSEGV(11), reason=SEGV_MAPERR, si_addr=0x10, randomSeed=1422360655
[ pid=25856 ] Crash log dumped to /var/tmp/passenger-crash-log.1422360930
[ pid=25856 ] Date, uname and ulimits:
Tue Jan 27 07:15:30 EST 2015
Linux 3.13.0-042stab094.8 #1 SMP Tue Dec 16 20:36:56 MSK 2014 x86_64 x86_64
time(seconds)        unlimited
file(blocks)         unlimited
data(kbytes)         unlimited
stack(kbytes)        10240
coredump(blocks)     0
memory(kbytes)       unlimited
locked memory(kbytes) 64
process              1029939
nofiles              8192
vmemory(kbytes)      unlimited
locks                unlimited
[ pid=25856 ] Phusion Passenger version: 5.0.0.beta2
[ pid=25856 ] libc backtrace available!
--------------------------------------
[ pid=25856 ] Backtrace with 23 frames:
Using backtrace sanitizer.
PassengerAgent server[0x4d08d3]
PassengerAgent server[0x4d0185]
PassengerAgent server[0x4d1483]
PassengerAgent server[0x4d213d]
/lib/x86_64-linux-gnu/libpthread.so.0(?? at ??:0; +0x10340) [0x7fb9f915c340]
PassengerAgent server[0x5013de]
PassengerAgent server[0x5050b9]
PassengerAgent server[0x6858fb]
PassengerAgent server[0x6878db]
PassengerAgent server[0x539c40]
PassengerAgent server[0x68111e]
PassengerAgent server[0x681ff8]
PassengerAgent server[0x539bc2]
PassengerAgent server[0x5c68c9]
PassengerAgent server[0x5c16ed]
PassengerAgent server[0x5bc69a]
PassengerAgent server[0x64f027]
PassengerAgent server[0x4cec46]
PassengerAgent server[0x4ce831]
PassengerAgent server[0x4ce01c]
PassengerAgent server[0x6226b9]
/lib/x86_64-linux-gnu/libpthread.so.0(?? at ??:0; +0x8182) [0x7fb9f9154182]
/lib/x86_64-linux-gnu/libc.so.6(?? at ??:0; clone+0x6d) [0x7fb9f845900d]
--------------------------------------
[ pid=25856 ] Dumping additional diagnostical information...
--------------------------------------
### Backtraces
Thread 'Main thread' (0x7fb9f99ef7c0, LWP 25856):
     in 'void waitForExitEvent()' (Main.cpp:778)
     in 'void mainLoop()' (Main.cpp:671)
     in 'int runServer()' (Main.cpp:893)

Thread 'Pool analytics collector' (0x7fb9f99ed700, LWP 25856):
     in 'static void
Passenger::ApplicationPool2::Pool::collectAnalytics(Passenger::ApplicationPool2::PoolPtr)' (Pool.h:829)

     Thread 'Pool garbage collector' (0x7fb9f99ac700, LWP 25856):
     in 'static void
Passenger::ApplicationPool2::Pool::garbageCollect(Passenger::ApplicationPool2::PoolPtr)' (Pool.h:684)

Thread 'Main event loop: thread 1' (0x7fb9f2a6c700, LWP 25856):
 (empty)

And the files goes on....

Also, at the end of error.log I see a:

 No locals.[ 2015-01-27 07:15:34.0702 12438/7f20597d2700 agents/Watchdog/AgentWatcher.cpp:96 ]: Phusion Passenger helper agent (pid=25856) crashed with signal SIGSEGV, restarting it...

[Tue Jan 27 07:15:34.077773 2015] [core:error] [pid 12483:tid 140022065903360]  [client 200.71.213.222:50038] End of script output before headers: profiles, referer: http://www.xxxxxxxxxxx.com/profiles/username-something/avatar/edit
[ 2015-01-27 07:15:34.0849 26021/7f56396e37c0 agents/HelperAgent/Main.cpp:881 ]: Starting PassengerAgent server...
[ 2015-01-27 07:15:34.0852 26021/7f56396e37c0 agents/HelperAgent/Main.cpp:232 ]: PassengerAgent server running in multi-application mode.
[ 2015-01-27 07:15:34.0965 26021/7f56396e37c0 agents/HelperAgent/Main.cpp:635 ]: PassengerAgent server online, PID 26021
App 26054 stdout: 
App 26071 stdout:

How can I try to resolve this issue? Thank you so much for your help


Source: (StackOverflow)

Rails Dragonfly find files in use

We are using Dragonfly for file and image upload in the app and in the Rails Admin.

Dragonfly in app part Users can apply for jobs and add their resume as attachment. When user uploads attachments and sucesfully apply for a job the files get deleted.

Dragonfly in Rails Admin part Admins can create pages with attachments and images in the Rails Admin part, these attachments are linked via the specific tables.

Problem When a user is applying for a job but doesn't finish the apply the files remain unused on the server. Now dragonfly stores the files from the Admin on the same place as the user uploaded files.

Question Is it possible to filter out the files that are not linked in the DB and bulk delete these files?


Source: (StackOverflow)

Rails + Dragonfly + Nginx - wrong root path for images.

I have Rails app that uses

 gem 'dragonfly-s3_data_store', '~> 1.0.0'

and uploads assets to S3.

Files upload just fine, but then they won't display. If I look at the logs I see this:

 *150 open() "/etc/nginx/html/system/images/W1siZiIsIjIwMTUvMDUvMjEvMTgvNDIvNTUvOTEwL3ByZXNzX3Nob3J0LnBuZyJdXQ/press_short.png" failed (2: No such file or directory), client: 173.225.73.29, server: SERVERNAME, request: "GET /system/images/W1siZiIsIjIwMTUvMDUvMjEvMTgvNDIvNTUvOTEwL3ByZXNzX3Nob3J0LnBuZyJdXQ/press_short.png?sha=b4bb5663e1358837 HTTP/1.1", host: "EC2-ADDDRESS", referrer: "http://ec2-XXXX.compute-1.amazonaws.com/"

Source: (StackOverflow)

How do you deploy rails app with dragonfly db on a different server?

RoR, Nginx, passenger, ubuntu14

I have 2 app servers and 1 db server all behind a load balancer. The 2 application servers grab their data from the db server. I would like to deploy the dragonfly file structure(user defined image assets) to the the db server so that regardless of which app server receives traffic, they will both be able to serve the user's images. Unfortunately I have not found much info on this. Can any one point me in the right direction? I have looked in to creating a new DB like MongoDB but there would be too much over head to migrate all of our data and having 2 databases on one server is not ideal..

              [ Load Balancer ]
               /           \
    [ app server 1 ]    [ app server 2 ]
                 \       /
         [ DB w/ dragonfly images ]

Source: (StackOverflow)

Adding Heroku CDN to RefineryCMS

Trying to use asset_sync in a RefineryCMS site on Heroku following this article. Worked out all the problems with rendering from the app/assets directory. Now I'm having issues with images and files uploaded to the site with dragonfly and stored in a separate S3 bucket previously.

Links should look like:

http://myapp.org/system/resources/W1siZiIsIjIwMTMvMDQvMDkvMTgvNDMvNTAvMTE1L0ZhbWlseV9FbnZlbG9wZV9NZXJnZV80XzlfMTMucGRmIl1d/Family%20Letter.pdf

This goes to the bucket I'd set up for uploaded files in config/initializers/images:

   config.s3_backend = Refinery::Core.s3_backend
   config.s3_bucket_name = ENV['S3_BUCKET']
   config.s3_access_key_id = ENV['S3_KEY']
   config.s3_secret_access_key = ENV['S3_SECRET']

This is a SEPARATE bucket from the one used for assets. The link I get instead is:

https://staging-assets.s3.amazonaws.com/system/images/W1siZiIsIjIwMTIvMTAvMDkvMDgvMDUvMjYvMTkxL09jdG9iZXJfQ2FsZW5kYXIuanBnIl0sWyJwIiwidGh1bWIiLCIxMzV4MTM1I2MiXV0/October%20Calendar.jpg

Do I have to transfer all my existing assets into the new bucket (in a "system" directory, I'd guess? Or is there a config var that I can set to say, "go here for dragonfly files"

EDIT: Just found this commit that may address this issue, but I'm not sure. Perhaps someone can clarify how to configure.


Source: (StackOverflow)

Why is Dragonfly resizing my images over and over again?

I load my images, and the first times it will run convert on them, so it's a little slow. But I expected it to never run convert on them again but DragonFly does it over and over again (in development mode).

2014-01-15 14:10:45.587 [fyi] Started GET "/media/W1siZiIsIjIwMTMvMTEvMTEvMTkvNTAvMDAvNTg3L2JsaW5kYmFyYmVyX2ZhY2lhbGNsZWFuc2VyLmpwZyJdLFsicCIsInRodW1iIiwiOTIweDkyMD4iXSxbInAiLCJlbmNvZGUiLCJqcGciLCItcXVhbGl0eSA0MCJdXQ/blindbarber-facialcleanser.jpg" for 127.0.0.1 at 2014-01-15 14:10:45 -0500 (pid:73447)
2014-01-15 14:10:47.149 [meh] DRAGONFLY: shell command: 'convert' '/var/folders/42/z4r6cjj10vb5c6zvtwb0m9000000gn/T/dragonfly20140115-73447-1ti4jze' '-resize' '920x920>' '/var/folders/42/z4r6cjj10vb5c6zvtwb0m9000000gn/T/dragonfly20140115-73447-fvdfam.jpg' (pid:73447)
2014-01-15 14:10:47.700 [meh] DRAGONFLY: shell command: 'convert' '/var/folders/42/z4r6cjj10vb5c6zvtwb0m9000000gn/T/dragonfly20140115-73447-fvdfam.jpg' '-quality' '40' '/var/folders/42/z4r6cjj10vb5c6zvtwb0m9000000gn/T/dragonfly20140115-73447-e10r7h.jpg' (pid:73447)
2014-01-15 14:10:47.804 [fyi] DRAGONFLY: GET /media/W1siZiIsIjIwMTMvMTEvMTEvMTkvNTAvMDAvNTg3L2JsaW5kYmFyYmVyX2ZhY2lhbGNsZWFuc2VyLmpwZyJdLFsicCIsInRodW1iIiwiOTIweDkyMD4iXSxbInAiLCJlbmNvZGUiLCJqcGciLCItcXVhbGl0eSA0MCJdXQ/blindbarber-facialcleanser.jpg 200 (pid:73447)
2014-01-15 14:10:47.807 [meh] Cache write: d857888f4b9a786a815372039d952e203c056795 (pid:73447)
2014-01-15 14:10:47.825 [meh] Cache read: d857888f4b9a786a815372039d952e203c056795 (pid:73447)
2014-01-15 14:10:47.826 [meh] Cache read: http://localhost:3000/media/W1siZiIsIjIwMTMvMTEvMTEvMTkvNTAvMDAvNTg3L2JsaW5kYmFyYmVyX2ZhY2lhbGNsZWFuc2VyLmpwZyJdLFsicCIsInRodW1iIiwiOTIweDkyMD4iXSxbInAiLCJlbmNvZGUiLCJqcGciLCItcXVhbGl0eSA0MCJdXQ/blindbarber-facialcleanser.jpg? (pid:73447)
2014-01-15 14:10:47.827 [meh] Cache write: http://localhost:3000/media/W1siZiIsIjIwMTMvMTEvMTEvMTkvNTAvMDAvNTg3L2JsaW5kYmFyYmVyX2ZhY2lhbGNsZWFuc2VyLmpwZyJdLFsicCIsInRodW1iIiwiOTIweDkyMD4iXSxbInAiLCJlbmNvZGUiLCJqcGciLCItcXVhbGl0eSA0MCJdXQ/blindbarber-facialcleanser.jpg? (pid:73447)

But for every request it will convert the images again, any idea why?

PS: My dragonfly.rb


Source: (StackOverflow)

Rails ckeditor dragonfly Erorr

Gem => https://github.com/galetahub/ckeditor

Rails = 4.1.4

I've done

rails generate ckeditor:install --orm=active_record --backend=dragonfly

ckeditor_dragonfly.rb

# Load Dragonfly for Rails if it isn't loaded already.
require "dragonfly/rails/images"

# Use a separate Dragonfly "app" for CKEditor.
app = Dragonfly[:ckeditor]
app.configure_with(:rails)
app.configure_with(:imagemagick)

# Define the ckeditor_file_accessor macro.
app.define_macro(ActiveRecord::Base, :ckeditor_file_accessor) if defined?(ActiveRecord::Base)
app.define_macro_on_include(Mongoid::Document, :ckeditor_file_accessor) if defined?(Mongoid::Document)

app.configure do |c|
  # Store files in public/uploads/ckeditor. This is not
  # mandatory and the files don't even have to be stored under
  # public. If not storing under public then set server_root to nil.
  c.datastore.root_path = Rails.root.join("public", "uploads", "ckeditor", Rails.env).to_s
  c.datastore.server_root = Rails.root.join("public").to_s

  # Accept asset requests on /ckeditor_assets. Again, this is not
  # mandatory. Just be sure to include :job somewhere.
  c.url_format = "/uploads/ckeditor/:job/:basename.:format"
end

# Insert our Dragonfly "app" into the stack.
Rails.application.middleware.insert_after Rack::Cache, Dragonfly::Middleware, :ckeditor

But when I try to do something, an error:

Dragonfly::App[:ckeditor] is deprecated - use Dragonfly.app (for the default app) or Dragonfly.app(:ckeditor) (for extra named apps) instead. See docs at http://markevans.github.io/dragonfly for details

NoMethodError: undefined method `configure_with' for Dragonfly:Module

What ideas are there to solve the problem?

UPD. If correct these errors, it becomes:

Dragonfly::Configurable::UnregisteredPlugin: plugin :rails is not registered

Source: (StackOverflow)

Why do some assets give 403 forbidden?

I am using ROR, nginx, passenger...

If there is no picture in the DB then my app will serve the 'default_avatar.png'. I noticed I was unable to save new pictures. So, I updated my dragonfly initializer to point at my db server:

...
  # I have obscured the host IP for this example. 
  config.url_host = Rails.env.production? ? 'http://IP_OF_HOST' : 'http://localhost:3000'
...

Now I can save pictures and view them through my app, but the 'default_avatar.png' does not resolve. Oddly enough, other image assets do seem to come through. Why do I get 403? At first guess I thought it was a permissions error. But then why would it serve the other images?

UPDATE:

I have just noticed a very important clue. When the assets do not work, they have the url:

/media/jakbfAGasgAgADSGANJGFDgbnadglnalgbakljbgkjabg/default_avatar.png

And when they do work:

/assets/avatar.png

I should mention that I have 2 app servers and 1 db server. I do not believe it to be a permissions error.


Source: (StackOverflow)