1
0
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:
Laurent Cozic
2018-10-04 08:17:53 +01:00
parent 99493174ec
commit 6b10d5d821
3 changed files with 18 additions and 16 deletions

View File

@@ -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') {