diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-31 22:35:02 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-31 22:35:02 +0900 |
| commit | 1a51b9870039da8b328acc673b2e8cb08ae2e663 (patch) | |
| tree | 71784c690f794cf0b3f37f3de56ce7316643da19 /src/misc | |
| parent | Revert "Clean up" (diff) | |
| download | sharkey-1a51b9870039da8b328acc673b2e8cb08ae2e663.tar.gz sharkey-1a51b9870039da8b328acc673b2e8cb08ae2e663.tar.bz2 sharkey-1a51b9870039da8b328acc673b2e8cb08ae2e663.zip | |
Refactor
Diffstat (limited to 'src/misc')
| -rw-r--r-- | src/misc/get-drive-file-url.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/misc/get-drive-file-url.ts b/src/misc/get-drive-file-url.ts new file mode 100644 index 0000000000..0fe467261e --- /dev/null +++ b/src/misc/get-drive-file-url.ts @@ -0,0 +1,20 @@ +import { IDriveFile } from '../models/drive-file'; +import config from '../config'; + +export default function(file: IDriveFile, thumbnail = false): string { + if (file == null) return null; + + if (file.metadata.withoutChunks) { + if (thumbnail) { + return file.metadata.thumbnailUrl || file.metadata.url; + } else { + return file.metadata.url; + } + } else { + if (thumbnail) { + return `${config.drive_url}/${file._id}?thumbnail`; + } else { + return `${config.drive_url}/${file._id}`; + } + } +} |