Git Product home page Git Product logo

carrierwave-dropbox's People

Contributors

astratto avatar brunoocasali avatar mcasimir avatar mful avatar qinix avatar robin850 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

carrierwave-dropbox's Issues

undefined method `gsub' for nil:NilClass

I followed tutorial here on Git and I am getting this error now. I have file in config/initializers/carrierwave.rb with filled dropbox API info:

CarrierWave.configure do |config|
  config.dropbox_app_key = ENV["APP_KEY"]
  config.dropbox_app_secret = ENV["APP_SECRET"]
  config.dropbox_access_token = ENV["ACCESS_TOKEN"]
  config.dropbox_access_token_secret = ENV["ACCESS_TOKEN_SECRET"]
  config.dropbox_user_id = ENV["USER_ID"]
  config.dropbox_access_type = "dropbox"
end

and I enabled storage :dropbox in my uploaders.

This error triggers on this line of code in my views (when I remove this line everything works fine):

= link_to image_tag(current_user.avatar.icon), root_url, :class => "circle icon"

OR when I remove this line and try to upload an image to Dropbox, here:

screen shot 2015-04-08 at 8 57 28 pm

Is this issue with my setup or something else?

v1_retired

Dropbox just ditched API v1 and I'm getting the error "v1_retired", I'm pretty new to this stuff and I couldn't find an answer onto how to make the gem work, is there a configuration I need to change in order to get API v2 to work or does the gem need to be updated?

undefined method 'content_type' for #Hash

I am trying to use publify with this gem. I could upload resources locally, but when I switched to carrierwave-dropbox I get the error Undefined method 'content_type' for #<Hash:0x0000000683a990> while the images are normally uploaded to my dropbox folder. Any idea why this is happening?
Here's the app trace

NoMethodError in Admin::ResourcesController#upload
undefined method `content_type' for #<Hash:0x0000000683a990>

app/uploaders/resource_uploader.rb:42:in `image?'
app/controllers/admin/resources_controller.rb:15:in `upload'

resource_uploader.rb

class ResourceUploader < CarrierWave::Uploader::Base
  storage :dropbox
  # To handle Base64 uploads...
  class FilelessIO < StringIO
    attr_accessor :original_filename

    def initialize(data, filename)
      super(data)
      @original_filename = filename
    end
  end

  include CarrierWave::MiniMagick
  include CarrierWave::MimeTypes

  process :set_content_type

  def store_dir
    "files/#{model.class.to_s.underscore}/#{model.id}"
  end

  version :thumb, :if => :image? do
    process :dynamic_resize_to_fit => :thumb
  end

  version :medium, :if => :image? do
    process :dynamic_resize_to_fit => :medium
  end

  version :avatar, :if => :image? do
    process :dynamic_resize_to_fit => :avatar
  end

  def dynamic_resize_to_fit(size)
    blog = Blog.default
    resize_setting = blog.send("image_#{size}_size").to_i

    resize_to_fit(resize_setting, resize_setting)
  end

  def image?(new_file)
    new_file.content_type && new_file.content_type.include?('image')
  end
end

resources_controller.rb

require 'fog'

class Admin::ResourcesController < Admin::BaseController
  cache_sweeper :blog_sweeper

  def upload
    if ! params[:upload].blank?
      file = params[:upload][:filename]

      unless file.content_type
        mime = 'text/plain'
      else
        mime = file.content_type.chomp
      end
      @up = Resource.create(:upload => file, :mime => mime, :created_at => Time.now)
      flash[:success] = I18n.t('admin.resources.upload.success')
    else
      flash[:warning] = I18n.t('admin.resources.upload.warning')
    end

    redirect_to :action => "index"
  end

  def index
    @r = Resource.new
    @resources = Resource.order('created_at DESC').page(params[:page]).per(this_blog.admin_display_elements)
  end

  def get_thumbnails
    position = params[:position].to_i
    @resources = Resource.without_images.by_created_at.limit(10).offset(position)

    render 'get_thumbnails', :layout => false
  end

  def destroy
    begin
      @record = Resource.find(params[:id])
      mime = @record.mime
      return(render 'admin/shared/destroy') unless request.post?

      @record.destroy
      flash[:notice] = I18n.t('admin.resources.destroy.notice')
      redirect_to :action => 'index'
    rescue
      raise
    end
  end
end

rake dropbox:authorize is not working

In Rails,

Rake Task:- rake dropbox:authorize APP_KEY=app_key APP_SECRET=app_secret ACCESS_TYPE=dropbox|app_folder is breaking

Got following error,

rake aborted!
Don't know how to build task 'dropbox:authorize'

(See full trace by running task with --trace)

DropboxAuthError: Error getting request token

Hi,

I got an error after this code line

rake dropbox:authorize APP_KEY=my_app_key APP_SECRET=my_app_secret ACCESS_TYPE=app_folder
rake aborted!
DropboxAuthError: Error getting request token. Is your app key and secret correctly set? Server returned 400: Bad Request.

Tasks: TOP => dropbox:authorize
(See full trace by running task with --trace)

Permission type is app folder on Dropbox.

Application status is still development mode and users 0/500

undefined method `gsub' for nil:NilClass

I followed the steps to get this up but I am getting the error
screen shot 2015-11-17 at 11 12 34 pm
"undefined method `gsub' for nil:NilClass"

I've looked at the old closed issues but they seem to be no help, so I decided to ask u guy directly

Here is my setup

config/initializers/carrierwave.rb
CarrierWave.configure do |config|
  config.dropbox_app_key = ENV["APP_KEY"]
  config.dropbox_app_secret = ENV["APP_SECRET"]
  config.dropbox_access_token = ENV["ACCESS_TOKEN"]
  config.dropbox_access_token_secret = ENV["ACCESS_TOKEN_SECRET"]
  config.dropbox_user_id = ENV["USER_ID"]
  config.dropbox_access_type = "app_folder"
  config.cache_dir = "#{Rails.root}/tmp/uploads"
end
/app/uploaders/avatar_uploader.rb
class AvatarUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick
  storage :dropbox

  def store_dir
    "profile_pics/"
  end

  process :resize_to_fit => [150, 150]

  def extension_white_list
    %w(jpg jpeg gif png)
  end
end
My controller
class ClassmatesController < ApplicationController
  def index
    @showNav = true
    @classmates = Classmate.all
  end

  def create
    @showNav = true
    @classmate = Classmate.new(params[:classmate])
    @classmate.avatar = params[:file]

    name = @classmate.name
    github = @classmate.githubProfile
    site = @classmate.website

    @classmate.githubProfile = ((github.split('//')[-1]).split('www.')[-1]).split('/')[-1]
    @classmate.website = ((site.split('//')[-1]).split('www.')[-1])

    respond_to do |format|
      if @classmate.save
        format.html { redirect_to action: "index"}
        format.json { render json: @classmate, status: :created, location: @classmate }
      else
        format.html { render action: "new" }
        format.json { render json: @classmate.errors, status: :unprocessable_entity }
      end
    end
  end
end

And the code is showing me that is it failing at:

if @classmates.save 

Please let me know anything I have been doing wrong, but I cant seem to fix this problem.

Thanks

Slow request speed.

I started using them gem about 2 days ago and I do like it a lot, I am using it to host uploaded images.

When I implemented and tested it on Openshift I ran into the issue of slow TTFB as well as incredibly slow downloading of the images on Dropbox which I'm not exactly sure why. This only happens on pages with the with Dropbox images.

Has anyone experienced this before? This is the site url https://francismb.com/projects

Image retrieve

Hi,

I'm using app_folder as access type for my app. Everything works fine when I upload files but I get a not found-error when I retrieve the files.

2013-12-28T10:45:36.275665+00:00 app[web.1]:   Parameters: {"id"=>"1"}
2013-12-28T10:45:36.646307+00:00 app[web.1]: Completed 500 Internal Server Error in 370ms
2013-12-28T10:45:36.649752+00:00 app[web.1]: app/controllers/application_controller.rb:61:in `minis'
2013-12-28T10:45:36.649752+00:00 app[web.1]: 
2013-12-28T10:45:36.649752+00:00 app[web.1]: DropboxError (Path '/uploads/mini_avatar-1.jpg' not found):
2013-12-28T10:45:36.649752+00:00 app[web.1]: 
2013-12-28T10:45:36.649752+00:00 app[web.1]: 
2013-12-28T10:45:36.652352+00:00 app[web.1]:   Parameters: {"id"=>"1"}
2013-12-28T10:45:36.652272+00:00 app[web.1]: Processing by ErrorsController#server_error as HTML
2013-12-28T10:45:37.014834+00:00 app[web.1]: Completed 500 Internal Server Error in 362ms
2013-12-28T10:45:37.014904+00:00 app[web.1]: Error during failsafe response: Path '/uploads/mini_avatar-1.jpg' not found
2013-12-28T10:45:37.014904+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.0.0/gems/dropbox-sdk-1.6.3/lib/dropbox_sdk.rb:111:in `parse_response'
2013-12-28T10:45:37.014904+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.0.0/gems/carrierwave-dropbox-1.1.1/lib/carrierwave/storage/dropbox.rb:60:in `url'
...

The path to that specific file should be (or was) https://dl.dropboxusercontent.com/1/view/qi6swqn3o11u6vq/Apps/AgileVentures/production/user/1/avatar-1.jpg so I assume that 'ulr' should be ...production/user/1/avatar-1.jpg

This is from production env on Heroku. http://websiteone.herokuapp.com/ , but I have same issues on my local machine as well.

My @client.media(path)["url"] outputs:
`!! #<DropboxError: Path '/uploads/mini_avatar-4.jpg' not found>``

My question is if the url is set and stored properly by the gem or if I'm doing something wrong.

Problem uploading files to Dropbox folder

First of all, thanks for creating this gem. I've been a big fan of the paperclip-dropbox gem (even created tutorial videos on it for my students at http://baserails.com). However, given many of the issues that the latest paperclip version has created for Windows users, I'm considering switching over to carrierwave for my next course and this gem seems like it could be a great fit.

I believe I've followed the installation and setup instructions pretty carefully, but I'm having trouble getting images to upload to my Dropbox folder. Everything worked fine using carrierwave alone, and I had no trouble getting the rake task to work. My image_uploader.rb file has 'storage :dropbox' set and my config/initializers/carrierwave.rb file has all the settings filled in (I'm using the 'app_folder' option if that matters).

When I upload an image, I'm noticing that my Dropbox folder has a new folder directory created at '/Apps/APPNAME/uploads/MODEL/image/1/', but the file itself isn't uploaded. No error is given while uploading, but trying to access the file with 'image_tag' results in "ActionView::Template::Error (Path '/Apps/APPNAME/uploads/MODEL/image/1/FILENAME.jpg' not found)". If it helps, the relevant param I see when the form is submitted is the following:
"image"=>#<ActionDispatch::Http::UploadedFile:0x007fc8ef049ad8 @tempfile=#<Tempfile:/var/folders/49/88yb4j0j70qfmb3wjwjj4jc80000gn/T/RackMultipart20140707-5214-1poq8gt>

Any help would be greatly appreciated!

Accessing file versions

In my uploader I am using minimagick to create several versions of my uploaded files.

class LogoUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick
  
  storage :dropbox
 
  version :thumb do
     process resize_to_fit: [100, 75]
  end
   
  version :medium do
     process resize_to_fit: [640, 480]
  end

end  

This seems to work fine and the original files as well as the thumb and medium size files are all generated and I can find them on Dropbox.

However, when I attempt to access the uploaded files in a view, only the medium version is returned. For example all three of these lines returns the medium sized image1.

  <%= image_tag @sponsor.logo.url if @sponsor.logo? %>
  <%= image_tag @sponsor.logo.url(:medium) if @sponsor.logo? %>
  <%= image_tag @sponsor.logo.url(:thumb) if @sponsor.logo? %>

Is there another way to access the other versions of the file?

Undefined method when running recreate_versions!

Using Dropbox as a storage with CarrierWave I'm trying to add a crop funtionality but when I try to update the attachment to upload I get
undefined method `read' for #CarrierWave::Storage::Dropbox::File:0x007ff74d572528

when trying to use recreate_versions! on the uploader, as far as I've gathered the problem is that the class CarrierWave::Storage::Dropbox::File does not have the methods from the Carrierwave base needed to run recreate_versions!

is this a bug? or is it a feature that was never done?

Below I have every relevant file, hope someone can give me a pointer.

class IssueObservation < ActiveRecord::Base
	attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
	mount_uploader :attachment, AttachmentUploader
	self.table_name = "IssueObservation"
	after_update :crop_attachment

  def crop_attachment
    attachment.recreate_versions! if crop_x.present?
  end
end
class AttachmentUploader < CarrierWave::Uploader::Base
	include CarrierWave::RMagick
  storage :dropbox

  version :thumb do
  	process :crop
	  resize_to_fill(100, 100)
	end

	version :large do
	  resize_to_limit(600, 600)
	end

	def crop
    if model.crop_x.present?
      resize_to_limit(600, 600)
      manipulate! do |img|
        x = model.crop_x
        y = model.crop_y
        w = model.crop_w
        h = model.crop_h
        img.crop!(x, y, w, h)
      end
    end
  end
  
  def store_dir
    "prueba/#{model.user_login}_#{model.id}"
  end

end
<h1>Crop Avatar</h1>
<%= image_tag @observation.attachment_url, id: "cropbox" %>
<h4>Preview</h4>
<div style="width:100px; height:100px; overflow:hidden">
  <%= image_tag @observation.attachment_url, :id => "preview" %>
</div>
<%= form_for @observation do |f| %>
  <% %w[x y w h].each do |attribute| %>
    <%= f.text_field "crop_#{attribute}" %>
  <% end %>
  <div class="actions">
    <%= f.submit "Crop" %>
  </div>
<% end %>
source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem 'sqlite3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use sqlite3 as the database for Active Record
gem "mysql2", "~> 0.4.5"
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass', '~> 3.3.6'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views

gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
gem "twitter-bootstrap-rails"
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'rails_admin', '~> 1.1.1'
gem 'rails_admin_material'
gem 'carrierwave'
gem 'carrierwave-dropbox'
gem 'rmagick'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
class IssueObservationsController < ApplicationController
	def update
	  @observation = IssueObservation.find(params[:id])
	  if @observation.update_attributes(issue_observation_params)
	    if issue_observation_params[:attachment].present?
	      render :crop
	    else
	      redirect_to rails_admin.show_path(model_name: @observation.class.name, id: @observation), notice: "Successfully updated observation."
	    end
	  else
	    render :new
	  end
	end
end
NoMethodError in IssueObservationsController#update
undefined method `read' for #<CarrierWave::Storage::Dropbox::File:0x007ff74e6dd6c8>

Extracted source (around line #11):
9
10
11
12
13
              

  def crop_attachment
    attachment.recreate_versions! if crop_x.present?
  end
end

Rails.root: /home/lhdev1/Projects/unfortracker

Application Trace | Framework Trace | Full Trace
carrierwave (0.11.2) lib/carrierwave/uploader/cache.rb:89:in `sanitized_file'
carrierwave (0.11.2) lib/carrierwave/uploader/cache.rb:128:in `cache!'
carrierwave (0.11.2) lib/carrierwave/uploader/versions.rb:226:in `recreate_versions!'
app/models/issue_observation.rb:11:in `crop_attachment'
activesupport (5.0.2) lib/active_support/callbacks.rb:382:in `block in make_lambda'
activesupport (5.0.2) lib/active_support/callbacks.rb:207:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:207:in `block in halting_and_conditional'
activesupport (5.0.2) lib/active_support/callbacks.rb:456:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:456:in `block in call'
activesupport (5.0.2) lib/active_support/callbacks.rb:456:in `each'
activesupport (5.0.2) lib/active_support/callbacks.rb:456:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.2) lib/active_support/callbacks.rb:750:in `_run_update_callbacks'
activerecord (5.0.2) lib/active_record/callbacks.rb:306:in `_update_record'
activerecord (5.0.2) lib/active_record/timestamp.rb:81:in `_update_record'
activerecord (5.0.2) lib/active_record/persistence.rb:540:in `create_or_update'
activerecord (5.0.2) lib/active_record/callbacks.rb:298:in `block in create_or_update'
activesupport (5.0.2) lib/active_support/callbacks.rb:126:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:126:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
activesupport (5.0.2) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.2) lib/active_support/callbacks.rb:750:in `_run_save_callbacks'
activerecord (5.0.2) lib/active_record/callbacks.rb:298:in `create_or_update'
activerecord (5.0.2) lib/active_record/persistence.rb:125:in `save'
activerecord (5.0.2) lib/active_record/validations.rb:44:in `save'
activerecord (5.0.2) lib/active_record/attribute_methods/dirty.rb:22:in `save'
activerecord (5.0.2) lib/active_record/transactions.rb:319:in `block (2 levels) in save'
activerecord (5.0.2) lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
activerecord (5.0.2) lib/active_record/connection_adapters/abstract/database_statements.rb:230:in `transaction'
activerecord (5.0.2) lib/active_record/transactions.rb:211:in `transaction'
activerecord (5.0.2) lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
activerecord (5.0.2) lib/active_record/transactions.rb:319:in `block in save'
activerecord (5.0.2) lib/active_record/transactions.rb:334:in `rollback_active_record_state!'
activerecord (5.0.2) lib/active_record/transactions.rb:318:in `save'
activerecord (5.0.2) lib/active_record/suppressor.rb:41:in `save'
activerecord (5.0.2) lib/active_record/persistence.rb:267:in `block in update'
activerecord (5.0.2) lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
activerecord (5.0.2) lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
activerecord (5.0.2) lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
activerecord (5.0.2) lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
activerecord (5.0.2) lib/active_record/transactions.rb:211:in `transaction'
activerecord (5.0.2) lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
activerecord (5.0.2) lib/active_record/persistence.rb:265:in `update'
app/controllers/issue_observations_controller.rb:13:in `update'
actionpack (5.0.2) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.0.2) lib/abstract_controller/base.rb:188:in `process_action'
actionpack (5.0.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.0.2) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.0.2) lib/active_support/callbacks.rb:126:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:126:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
activesupport (5.0.2) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.2) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.2) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
activesupport (5.0.2) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.2) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.0.2) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.0.2) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.2) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.2) lib/active_support/notifications.rb:164:in `instrument'
actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.0.2) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
activerecord (5.0.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (5.0.2) lib/abstract_controller/base.rb:126:in `process'
actionview (5.0.2) lib/action_view/rendering.rb:30:in `process'
actionpack (5.0.2) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (5.0.2) lib/action_controller/metal.rb:262:in `dispatch'
actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (5.0.2) lib/action_dispatch/journey/router.rb:39:in `block in serve'
actionpack (5.0.2) lib/action_dispatch/journey/router.rb:26:in `each'
actionpack (5.0.2) lib/action_dispatch/journey/router.rb:26:in `serve'
actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:725:in `call'
rack-pjax (1.0.0) lib/rack/pjax.rb:12:in `call'
remotipart (1.3.1) lib/remotipart/middleware.rb:32:in `call'
rack (2.0.1) lib/rack/etag.rb:25:in `call'
rack (2.0.1) lib/rack/conditional_get.rb:38:in `call'
rack (2.0.1) lib/rack/head.rb:12:in `call'
rack (2.0.1) lib/rack/session/abstract/id.rb:222:in `context'
rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call'
actionpack (5.0.2) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.0.2) lib/active_record/migration.rb:553:in `call'
actionpack (5.0.2) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.2) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.2) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.2) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.2) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
actionpack (5.0.2) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.2) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
web-console (3.5.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.5.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.5.0) lib/web_console/middleware.rb:18:in `catch'
web-console (3.5.0) lib/web_console/middleware.rb:18:in `call'
actionpack (5.0.2) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.2) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.2) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.2) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.0.2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.2) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.0.2) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.0.2) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.0.1) lib/rack/method_override.rb:22:in `call'
rack (2.0.1) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.2) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.2) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
railties (5.0.2) lib/rails/engine.rb:522:in `call'
puma (3.8.2) lib/puma/configuration.rb:224:in `call'
puma (3.8.2) lib/puma/server.rb:600:in `handle_request'
puma (3.8.2) lib/puma/server.rb:435:in `process_client'
puma (3.8.2) lib/puma/server.rb:299:in `block in run'
puma (3.8.2) lib/puma/thread_pool.rb:120:in `call'
puma (3.8.2) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Request

Parameters:

{"utf8"=>"โœ“",
 "_method"=>"patch",
 "authenticity_token"=>"vWSzzeqpPvW5btjlQLy0j3/XewHNw4GfhHBLdeQ28bnqJLDrJCwzFZAe9+N2zXxEQUYEx+ihZJkO5jpu7prCxA==",
 "issue_observation"=>{"crop_x"=>"8", "crop_y"=>"30", "crop_w"=>"242", "crop_h"=>"242"},
 "commit"=>"Crop",
 "id"=>"6"}

Thanks

Dropbox make private "public folder"

Dropbox announce me this change two weeks ago, and from yesterday user can't access to files from my app. (i'm using access_type = "dropbox")
Does anyone know a workaround?

Use image from uploaded file in image_tag

I've registered an app on Dropbox, authorised it with App folder permission type. In config/initializers/carrierwave.rp I've set config.dropbox_access_type = "app_folder" along with appropriate app keys and access tokens.

File saving works just fine, but when I try to get the URL to the file, I get URL lik https://dl.dropboxusercontent.com/u/<user_id>/uploads/<file>. Visiting the link returns 404 and using it with image_tag doesn't display the image (surprise, surprise). What do I need to do in order to display the uploaded image correctly?

undefined method `gsub' for nil:NilClass

Hi,

I'm getting undefined method 'gsub' for nil:NilClass when trying to upload file to dropbox.

My /config/initializers/carrierwave.rblooks like this:

CarrierWave.configure do |config|
  config.root = Rails.root.join('tmp')
  config.dropbox_app_key = ENV["..."]
  config.dropbox_app_secret = ENV["..."]
  config.dropbox_access_token = ENV["..."]
  config.dropbox_access_token_secret = ENV["..."]
  config.dropbox_user_id = ENV["..."]
  config.dropbox_access_type = "dropbox"
end

In uploaders/avataruploader.rb i have:

storage :dropbox

skarmavbild 2013-12-23 kl 14 10 05

What have I missed?

Support for dropbox short-lived tokens

Dropbox does not allow creation of long-lived access tokens anymore (guide). Short-lived access tokens are now the default. Are there planes to update this gem to work with short-lived tokens?

DropboxAuthError (User is not authenticated.)

I have created new app on Dropbox.com/developers. And authorized using rake task.
rake dropbox:authorize APP_KEY=app_key APP_SECRET=app_secret ACCESS_TYPE..

After authorized, It says DropboxAuthError (User is not authenticated) error.

rails g uploader image is not working

Got following error while running rails g uploader image

/config/initializers/carrierwave.rb:2:in block in <top (required)>': undefined methoddropbox_app_key=' for CarrierWave::Uploader::Base:Class (NoMethodError)

Still mantained?

Because is of this Dropbox::ClientError (Invalid access token):

Slow attachment.url's

The Following code fixes slow rendering / url retrieval issues when a model has an attachment.url:

class ImageUploader < CarrierWave::Uploader::Base

 def url  
 "dropbox_endpoin_manually_typed/#{path}" if path
  end
end

Before the fix = (Views: ~1800ms | ActiveRecord: 0.7ms)

After the fix = (Views: ~10ms | ActiveRecord: 0.7ms)

Check whether image exists or not in dropbox

I am using the following method to check whether the image exists or not in dropbox, But it shows "true" even if the image is not present.

My uploader:

class Avatar < CarrierWave::Uploader::Base
    include CarrierWave::MiniMagick
    storage: dropbox
    def store_dir
        if model
          "uploads/#{model.class.to_s.underscore}/#{model.id}/#{mounted_as}"
        else
          "uploads/#{mounted_as}/"
        end
     end 
 end

Console output:

>Article.first.avatar?
>true
    #<AvatarUploader:0x007f8574143ee8
@file=
 #<CarrierWave::Storage::Dropbox::File:0x007f8574143308
  @client=
  #<DropboxClient:0x007f8574143420
   @root="dropbox",
   @session=
    #<DropboxSession:0x007f8574143498
    @access_token=#<OAuthToken:0x007f8574143470 @key="123453333",      @secret="22222222222">,
   @consumer_key="abcdeafs",
   @consumer_secret="asdfasfj",
   @locale=nil,
   @request_token=nil>>,
   @config=
{:app_key=>"asdfasfasf",
 :app_secret=>"asdfkasfksf",
 :access_token=>"adfkjasfkhs",
 :access_token_secret=>"aksdfkhsfksf",
 :access_type=>"dropbox",
 :user_id=>"292929292"},
 @path="uploads/images/370/avatar.png",
 @uploader=#<AvatarUploader:0x007f8574143ee8 ...>>,
 @model=
  #Artcle Model>,
  @mounted_as=:image,
  @storage=
  #<CarrierWave::Storage::Dropbox:0x007f8574143c90
   @config=
    {:app_key=>"asdfasfasf",
    :app_secret=>"asdfkasfksf",
    :access_token=>"adfkjasfkhs",
    :access_token_secret=>"aksdfkhsfksf",
    :access_type=>"dropbox",
    :user_id=>"292929292"},
   @dropbox_client=
  #<DropboxClient:0x007f8574143420
   @root="dropbox",
   @session=

I should get "false" when the image is not present in dropbox. Kindly help me to solve this.

rake task: Couldn't get access token. Server returned 401: Unauthorized.

I created app in Dropbox with app folder permission type. When I run rake task:

rake dropbox:authorize APP_KEY=xxx APP_SECRET=xxx ACCESS_TYPE=app_folder

I get an error:

Visit this URL: https://www.dropbox.com/1/oauth/authorize?oauth_token=kECiTB7Su081iODs
And after you approved the authorization confirm it here (y/n): y
W, [2014-07-29T09:11:36.501940 #31832]  WARN -- : ** [Bugsnag] No API key configured, couldn't notify
rake aborted!
DropboxAuthError: Couldn't get access token.  Server returned 401: Unauthorized.
/Users/ograbek/.rvm/gems/ruby-2.1.2@uke_geocoder/gems/dropbox-sdk-1.6.4/lib/dropbox_sdk.rb:263:in `get_token'
/Users/ograbek/.rvm/gems/ruby-2.1.2@uke_geocoder/gems/dropbox-sdk-1.6.4/lib/dropbox_sdk.rb:337:in `get_access_token'
/Users/ograbek/.rvm/gems/ruby-2.1.2@uke_geocoder/gems/carrierwave-dropbox-1.2.1/lib/carrierwave/dropbox/rake.rb:17:in `authorize'
/Users/ograbek/.rvm/gems/ruby-2.1.2@uke_geocoder/gems/carrierwave-dropbox-1.2.1/lib/carrierwave/dropbox/authorize.rake:11:in `block (2 levels) in <top (required)>'

Key and secret are correct. When I visited this URL:

https://www.dropbox.com/1/oauth/authorize?oauth_token=kECiTB7Su081iODs

I could be able to authorize access. Should I do something more ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.