Video Uploading with Rails and dragonfly-gem

192 views
Skip to first unread message

Michael Blum

unread,
Nov 30, 2015, 9:07:33 AM11/30/15
to Dragonfly
Hello!

I am using Dragonfly in rails. I have implemented it according to this tutorial and it is working very good.

Now I want to also upload videofiles. Unfortunately I am not able to get it running. :(
I hope you guys can help me find the error:


initializers/dragonfly.rb

require 'dragonfly'

# Configure
Dragonfly.app.configure do
  plugin
:imagemagick

  secret
'd045734b043b4383a246c5c8daf2d3e31217dc8b030f21861e4fd16c4b72d382'

  url_format
'/media/:job/:name'

  datastore
:file,
            root_path
: Rails.root.join('uploads/images/'),
            server_root
: Rails.root.join('uploads')
end

Dragonfly.app(:videos).configure do
  secret
'd045734b043b4383a246c5c8daf2d3e31217dc8b030f21861e4fd16c4b72d382'

  url_format
"/media/:job/:name"

  datastore
:file,
            root_path
: Rails.root.join('uploads/videos/'),
            server_root
: Rails.root.join('uploads')
end

# Logger
Dragonfly.logger = Rails.logger

# Mount as middleware
Rails.application.middleware.use Dragonfly::Middleware
Rails.application.middleware.use Dragonfly::Middleware, :videos

# Add model functionality
if defined?(ActiveRecord::Base)
 
ActiveRecord::Base.extend Dragonfly::Model
 
ActiveRecord::Base.extend Dragonfly::Model::Validations
end


Video-Model:

class Video < ActiveRecord::Base

  dragonfly_accessor
:video, app: :videos, app_name: :videos do
    storage_options
do |video|
     
{ path: "videos/#{Video.video_uid}-#{video.name}.webm" }
   
end
 
end
end

Video-Controller: (extract)

@video = Video.new(video_params)
@video.save


Now when I upload a video, it correctly calles the video-controller and it is correctly saved in the database! But unfortunately the video can not be found in the desired directory (uploads/videos/).
What am I doing wrong?
I hope you can help me.

Best regards
Michael

Nathan Hessler

unread,
Nov 30, 2015, 9:32:25 AM11/30/15
to dragonf...@googlegroups.com
hey Michael,

I believe if you’re going to do more than one app, you have to name all the apps. I would go back to your default app and make sure it’s using a name like ‘:images’ as well.

regards

- Nathan


--
You received this message because you are subscribed to the Google Groups "Dragonfly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dragonfly-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Blum

unread,
Nov 30, 2015, 10:26:39 AM11/30/15
to Dragonfly
Thank you very much! That was the solution!

Nathan Hessler

unread,
Nov 30, 2015, 11:22:15 AM11/30/15
to dragonf...@googlegroups.com
glad I could help.

- Nathan

Suraj Mehta

unread,
Apr 3, 2017, 1:59:37 AM4/3/17
to Dragonfly
Hello there,
I am looking to create a rails app to upload a video to m google drive. Could you please guide me how I could achieve this. 

Thanks.
Reply all
Reply to author
Forward
0 new messages