Skip to content

Commit 5941200

Browse files
authored
Merge pull request #9 from robkooper/return-thumbnail
return thumbnail (fixes #8)
2 parents 3b84e70 + ec95e74 commit 5941200

File tree

3 files changed

+44
-24
lines changed

3 files changed

+44
-24
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [Unreleased]
8+
9+
### Fixed
10+
- Return thumbnail as part of the file information.
11+
[#8](https://github.com/clowder-framework/clowder/issues/8)
12+
713
## 1.9.0 - 2020-06-01
814
**_Warning:_ This update modifies information stored in Elasticsearch used for text based searching. To take advantage
915
of these changes a reindex of Elasticsearch is required. A reindex can be started by an admin from the Admin menu.**

app/api/Files.scala

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -728,42 +728,29 @@ class Files @Inject()(
728728
"content-type" -> file.contentType,
729729
"date-created" -> file.uploadDate.toString(),
730730
"size" -> file.length.toString,
731+
"thumbnail" -> file.thumbnail_id.orNull,
731732
"authorId" -> file.author.id.stringify,
732733
"status" -> file.status)
733734

734735
// Only include filepath if using DiskByte storage and user is serverAdmin
735736
val jsonMap = file.loader match {
736737
case "services.filesystem.DiskByteStorageService" => {
737738
if (serverAdmin)
738-
Map(
739-
"id" -> file.id.toString,
740-
"filename" -> file.filename,
741-
"filepath" -> file.loader_id,
742-
"filedescription" -> file.description,
743-
"content-type" -> file.contentType,
744-
"date-created" -> file.uploadDate.toString(),
745-
"size" -> file.length.toString,
746-
"authorId" -> file.author.id.stringify,
747-
"status" -> file.status)
739+
defaultMap ++ Map(
740+
"filepath" -> file.loader_id
741+
)
748742
else
749743
defaultMap
750744
}
751745
case "services.s3.S3ByteStorageService" => {
752746
if (serverAdmin) {
753747
val bucketName = configuration.getString(S3ByteStorageService.BucketName).getOrElse("")
754748
val serviceEndpoint = configuration.getString(S3ByteStorageService.ServiceEndpoint).getOrElse("")
755-
Map(
756-
"id" -> file.id.toString,
757-
"filename" -> file.filename,
749+
defaultMap ++ Map(
758750
"service-endpoint" -> serviceEndpoint,
759751
"bucket-name" -> bucketName,
760-
"object-key" -> file.loader_id,
761-
"filedescription" -> file.description,
762-
"content-type" -> file.contentType,
763-
"date-created" -> file.uploadDate.toString(),
764-
"size" -> file.length.toString,
765-
"authorId" -> file.author.id.stringify,
766-
"status" -> file.status)
752+
"object-key" -> file.loader_id
753+
)
767754
} else
768755
defaultMap
769756
}

public/swagger.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ paths:
272272
- files
273273
summary: Retrieve physical file object metadata
274274
description: |
275-
Get metadata of the file object (not the resource it describes) as JSON.
275+
Get information of the file object (not the resource it describes) as JSON.
276276
For example, size of file, date created, content type, filename.
277277
parameters:
278278
- name: id
@@ -281,9 +281,16 @@ paths:
281281
schema:
282282
type: string
283283
responses:
284-
200:
285-
description: OK
286-
content: {}
284+
'200':
285+
description: Successfully returns a list of files
286+
content:
287+
application/json:
288+
schema:
289+
$ref: '#/components/schemas/File'
290+
'401':
291+
$ref: '#/components/responses/Disabled'
292+
'404':
293+
$ref: '#/components/responses/NotFound'
287294
post:
288295
tags:
289296
- files
@@ -5363,13 +5370,16 @@ components:
53635370
properties:
53645371
id:
53655372
type: string
5373+
example: "5b8e969d5e0e8690971ee23e"
53665374
filename:
53675375
type: string
5376+
example: "cat.jpg"
53685377
filepath:
53695378
type: string
53705379
description: |
53715380
only specified if user is serveradmin, and storage is
53725381
DiskByteStorageService
5382+
example: "/home/clowder/data/uploads/41/e2/1e/5b8e969d5e0e8690971ee241"
53735383
service-endpoint:
53745384
type: string
53755385
description: |
@@ -5387,18 +5397,35 @@ components:
53875397
S3ByteStorageService
53885398
filedescription:
53895399
type: string
5400+
example: "Picture of a cat"
53905401
content-type:
53915402
type: string
5403+
example: "image/jpeg"
53925404
date-created:
53935405
type: string # should be date-time
5406+
example: "Tue Sep 04 09:28:45 CDT 2018"
53945407
size:
53955408
type: string # should be integer int64
53965409
format: int64
5410+
example: "190497"
53975411
authorId:
53985412
type: string # should be miniuser
5413+
description: id of user who uploaded the file
53995414
#$ref: '#/components/schemas/MiniUser'
5415+
example: "5447f889fa429866bbd44dbd"
5416+
thumbnail:
5417+
type: string
5418+
description: |
5419+
optinal id of the thumbnail image of this file
5420+
example: "5bfd5a2640c6cd6147bb27e0"
54005421
status:
54015422
type: string # should be enum
5423+
description: |
5424+
status of the file, this can be one of the following:
5425+
- CREATED file is created, but blob is not in final place yes
5426+
- PROCESSING blob is in final place, final processing is done such as sending messagess to RabbitMQ
5427+
- PROCESSED file is fully procesed by clowder
5428+
example: "PROCESSED"
54025429
MiniUser:
54035430
type: object
54045431
Space:

0 commit comments

Comments
 (0)