Retrieves a thumbnail, or smaller image representation, of a file.
Sizes of 32x32
,64x64
, 128x128
, and 256x256
can be returned in
the .png
format and sizes of 32x32
, 160x160
, and 320x320
can be returned in the .jpg
format.
Thumbnails can be generated for the image and video file formats listed found on our community site.
png
The file format for the thumbnail
Value is one of png
,jpg
12345
The unique identifier that represents a file.
The ID for any file can be determined
by visiting a file in the web application
and copying the ID from the URL. For example,
for the URL https://*.app.box.com/files/123
the file_id
is 123
.
320
32
320
The maximum height of the thumbnail
320
32
320
The maximum width of the thumbnail
32
32
320
The minimum height of the thumbnail
32
32
320
The minimum width of the thumbnail
When a thumbnail can be created the thumbnail data will be returned in the body of the response.
When a thumbnail can be created the thumbnail data will be returned in the body of the response.
Sometimes generating a thumbnail can take a few seconds. In these
situations the API returns a Location
-header pointing to a
placeholder graphic for this file type.
The placeholder graphic can be used in a user interface until the
thumbnail generation has completed. The Retry-After
-header indicates
when to the thumbnail will be ready. At that time, retry this endpoint
to retrieve the thumbnail.
Returns an error when Box is not able to create a thumbnail for this file type.
Instead, a Location
-header pointing to a placeholder graphic for
this file type will be returned.
Returns an error if some of the parameters are missing or not valid.
requested_preview_unavailable
- an incorrect dimension was
requested. This will happen if the dimension requested is
larger or smaller than the available file sizes for the thumbnail
format, or when when any of the size constraints contradict
each other.Returned when the access token provided in the Authorization
header
is not recognized or not provided.
Returned if the file is not found, or the user does not have access to the file, or for additional reasons.
preview_cannot_be_generated
- Box does not support thumbnails
for this type of fileAn unexpected client error.
curl -i -X GET "https://api.box.com/2.0/files/12345/thumbnail.png" \
-H "authorization: Bearer <ACCESS_TOKEN>"
await client.files.getFileThumbnailById(
thumbnailFile.id,
'png' as GetFileThumbnailByIdExtension,
);
client.files.get_file_thumbnail_by_id(
thumbnail_file.id, GetFileThumbnailByIdExtension.PNG
)
await client.Files.GetFileThumbnailByIdAsync(fileId: thumbnailFile.Id, extension: GetFileThumbnailByIdExtension.Png);
try await client.files.getFileThumbnailById(fileId: thumbnailFile.id, extension_: GetFileThumbnailByIdExtension.png, downloadDestinationURL: destinationPath)
file_id = '11111'
thumbnail = client.file(file_id).get_thumbnail_representation('92x92', extension='jpg')
Stream thumbnailContents = await client.FilesManager.GetThumbnailAsync("11111", maxWidth: 160, maxHeight: 160);
client.files.getThumbnail(forFile: "11111", extension: .png) { (result: Result<Data, BoxSDKError>) in
guard case let .success(thumbnailData) = result else {
print("Error getting file thumbnail")
return
}
let thumbnailImage = UIImage(data: thumbnailData)
}