mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-29 12:26:43 -06:00
bcb04924ff
* Image for Web * Add comment * Make main to original
29 lines
842 B
TypeScript
29 lines
842 B
TypeScript
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.webpublicUrl || file.metadata.url;
|
|
} else {
|
|
return file.metadata.webpublicUrl || file.metadata.url;
|
|
}
|
|
} else {
|
|
if (thumbnail) {
|
|
return `${config.drive_url}/${file._id}?thumbnail`;
|
|
} else {
|
|
return `${config.drive_url}/${file._id}?web`;
|
|
}
|
|
}
|
|
}
|
|
|
|
export function getOriginalUrl(file: IDriveFile) {
|
|
if (file.metadata && file.metadata.url) {
|
|
return file.metadata.url;
|
|
}
|
|
|
|
const accessKey = file.metadata ? file.metadata.accessKey : null;
|
|
return `${config.drive_url}/${file._id}${accessKey ? '?original=' + accessKey : ''}`;
|
|
}
|