Comments (4)
This was undocumented. I've updated the docs now.
Here's an example of how you can save a thumbnail:
client = DropboxApi::Client.new
File.open("thumbnail.png", "w") do |file|
client.get_thumbnail "/dropbox_image.png" do |thumbnail_content|
file.write thumbnail_content
end
end
Please re-open if anything is still unclear.
from dropbox_api.
Just to clarify, get_thumbnail
seems to be returning DropboxApi::Metadata::File
which wouldn't include the thumbnail
from dropbox_api.
Hi Jesús.
I've a similar problem for display a thumbnail.
ApplicationController
before_action :authenticator, :dropbox_client
CLIENT_ID = "XXXXXXX"
CLIENT_SECRET = "YYYYYY"
CODE = 'ZZZZZZZ'
private
def authenticator
DropboxApi::Authenticator.new(CLIENT_ID, CLIENT_SECRET)
end
def dropbox_client
@dropbox_client ||= DropboxApi::Client.new(CODE)
end
DropboxController.
def list
files = dropbox_client.list_folder "/#{params[:folder_code]}"
@files = files.entries
end
ApplicationHelper
def show_image(image)
File.open("thumbnail.png", "w") do |file|
@dropbox_client.get_thumbnail image.path_lower do |thumbnail_content|
file.write thumbnail_content
end
end
end
List.html.erb
<%= show_image(file) %>
Error.
"\xFF" from ASCII-8BIT to UTF-8
I changed File.open("thumbnail.png", "w") do |file| to File.open("thumbnail.png", "wb") do |file|
and as result I had #DropboxApi::Metadata::File:0x00007f834900f770
How to preview the thumbnail? image_tag, img_src?
Thanks so much. 👍
Gracias.
http://www.xuuso.com/dropbox_api/DropboxApi/Client.html
from dropbox_api.
Looks like you're trying to download the file to your server on every browser request.
It would make more sense to download the thumbnail to your server once, then serving it just like any other asset.
Anyway, the mistake in your example was that you're failing to generate the image tag, you're embedding the bytes of the image as part of the HTML document. Instead, your view you should have something like:
<%= image_tag("/path/to/downloaded/file/thumbnail.png") %>
from dropbox_api.
Related Issues (20)
- How to generate a link to a dropbox folder? HOT 5
- When will you release the next version? HOT 2
- Release v0.1.11
- Net::OpenTimeout at... execution expired HOT 3
- List_folder result entries breaks for shared folder HOT 1
- Access data value HOT 1
- Please upgrade dependency faraday to ~> 0.17 HOT 2
- Anyway to download online file with dl=0 or dl=1? HOT 1
- please use more reasonable faraday restriction, allow 1.0.1? HOT 3
- Please update search endpoint to use the v2 path HOT 4
- Refresh tokens support HOT 6
- Catching 401 HOT 2
- WARNING: Faraday::Connection#authorization HOT 1
- Token is malformed, Expecting "Bearer <oauth2-access-token>" HOT 2
- Dropbox
- support faraday 2.0? HOT 5
- The client doesn't work for the business api access token. HOT 1
- update to 2.x of `oauth` gem as dependency? HOT 3
- How do you get the token_hash for refresh tokens? HOT 3
- NoMethodError raised when dropbox responds with 429
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dropbox_api.