mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-26 21:12:59 +02:00
This commit is contained in:
parent
74cd19f942
commit
f8b7d20255
@ -326,6 +326,26 @@ describe('services_rest_Api', function() {
|
||||
expect(response.body.indexOf(resource.id) >= 0).toBe(true);
|
||||
}));
|
||||
|
||||
it('should not compress images uploaded through resource api', (async () => {
|
||||
const originalImagePath = `${__dirname}/../tests/support/photo-large.png`;
|
||||
await api.route(RequestMethod.POST, 'resources', null, JSON.stringify({
|
||||
title: 'testing resource',
|
||||
}), [
|
||||
{
|
||||
path: originalImagePath,
|
||||
},
|
||||
]);
|
||||
|
||||
const resources = await Resource.all();
|
||||
expect(resources.length).toBe(1);
|
||||
const uploadedImagePath = Resource.fullPath(resources[0]);
|
||||
|
||||
const originalImageSize = (await shim.fsDriver().stat(originalImagePath)).size;
|
||||
const uploadedImageSize = (await shim.fsDriver().stat(uploadedImagePath)).size;
|
||||
|
||||
expect(originalImageSize).toEqual(uploadedImageSize);
|
||||
}));
|
||||
|
||||
it('should delete resources', (async () => {
|
||||
const f = await Folder.save({ title: 'mon carnet' });
|
||||
|
||||
|
BIN
packages/app-cli/tests/support/photo-large.png
Normal file
BIN
packages/app-cli/tests/support/photo-large.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
@ -51,7 +51,10 @@ export default async function(request: Request, id: string = null, link: string
|
||||
if (!request.files.length) throw new ErrorBadRequest('Resource cannot be created without a file');
|
||||
const filePath = request.files[0].path;
|
||||
const defaultProps = request.bodyJson(readonlyProperties('POST'));
|
||||
return shim.createResourceFromPath(filePath, defaultProps, { userSideValidation: true });
|
||||
return shim.createResourceFromPath(filePath, defaultProps, {
|
||||
userSideValidation: true,
|
||||
resizeLargeImages: 'never',
|
||||
});
|
||||
}
|
||||
|
||||
return defaultAction(BaseModel.TYPE_RESOURCE, request, id, link);
|
||||
|
Loading…
x
Reference in New Issue
Block a user