You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Api: Fixes #843: Fixed regression that was preventing resource metadata from being downloaded
This commit is contained in:
@@ -265,20 +265,22 @@ class Api {
|
||||
// size: 164394
|
||||
|
||||
if (request.method === 'GET') {
|
||||
if (link !== 'file') throw new ErrorNotFound();
|
||||
if (link === 'file') {
|
||||
const resource = await Resource.load(id);
|
||||
if (!resource) throw new ErrorNotFound();
|
||||
|
||||
const resource = await Resource.load(id);
|
||||
if (!resource) throw new ErrorNotFound();
|
||||
const filePath = Resource.fullPath(resource);
|
||||
const buffer = await shim.fsDriver().readFile(filePath, 'Buffer');
|
||||
|
||||
const response = new ApiResponse();
|
||||
response.type = 'attachment';
|
||||
response.body = buffer;
|
||||
response.contentType = resource.mime;
|
||||
response.attachmentFilename = Resource.friendlyFilename(resource);
|
||||
return response;
|
||||
}
|
||||
|
||||
const filePath = Resource.fullPath(resource);
|
||||
const buffer = await shim.fsDriver().readFile(filePath, 'Buffer');
|
||||
|
||||
const response = new ApiResponse();
|
||||
response.type = 'attachment';
|
||||
response.body = buffer;
|
||||
response.contentType = resource.mime;
|
||||
response.attachmentFilename = Resource.friendlyFilename(resource);
|
||||
return response;
|
||||
if (link) throw new ErrorNotFound();
|
||||
}
|
||||
|
||||
if (request.method === 'POST') {
|
||||
|
||||
Reference in New Issue
Block a user