mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-15 09:04:04 +02:00
28 lines
618 B
JavaScript
28 lines
618 B
JavaScript
import { BaseModel } from 'lib/base-model.js';
|
|
import { Setting } from 'lib/models/setting.js';
|
|
import { mime } from 'lib/mime-utils.js';
|
|
import { filename } from 'lib/path-utils.js';
|
|
|
|
class Resource extends BaseModel {
|
|
|
|
static tableName() {
|
|
return 'resources';
|
|
}
|
|
|
|
static itemType() {
|
|
return BaseModel.MODEL_TYPE_RESOURCE;
|
|
}
|
|
|
|
static fullPath(resource) {
|
|
let extension = mime.toFileExtension(resource.mime);
|
|
extension = extension ? '.' + extension : '';
|
|
return Setting.value('resourceDir') + '/' + resource.id + extension;
|
|
}
|
|
|
|
static pathToId(path) {
|
|
return filename(path);
|
|
}
|
|
|
|
}
|
|
|
|
export { Resource }; |