Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check whether image exists or not in dropbox #18

Open
smmanoj opened this issue Apr 21, 2015 · 0 comments
Open

Check whether image exists or not in dropbox #18

smmanoj opened this issue Apr 21, 2015 · 0 comments

Comments

@smmanoj
Copy link

smmanoj commented Apr 21, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant