Check whether image exists or not in dropbox
smmanoj opened this issue · 0 comments
smmanoj commented
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.