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

Add an endpoint to make it easier to replace thumbnails #1253

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

manthey
Copy link
Member

@manthey manthey commented Aug 2, 2023

This also allows attaching data to large_image files.

The core of this work is

datafile = Upload().uploadFromFile(
    io.BytesIO(data), size=len(data),
    name='_largeImageThumbnail', parentType='item', parent=item,
    user=user, mimeType=mimeType, attachParent=True)
datafile.update({
    'isLargeImageThumbnail' if thumbnail is not False else 'isLargeImageData': True,
    'thumbnailKey': key,
})
datafile = File().save(datafile)

where data is the binary data to store, item is the girder item, and key is the standardizes key for the thumbnail/data (e.g., {"height":100,"width":160}, where order and spacing matter).

The new endpoint replaces an existing thumbnail or adds if it doesn't exist.

This also allows attaching data to large_image files.
@manthey manthey merged commit fa247f3 into master Aug 2, 2023
@manthey manthey deleted the replace-thumbnail-endpoint branch August 2, 2023 17:58
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

Successfully merging this pull request may close these issues.

1 participant