Skip to content

Commit 8d2dc74

Browse files
authored
Allow uploading empty files (#374)
* fix: allow uploading empty files * test: update tests
1 parent 919eefc commit 8d2dc74

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

packages/runtime/src/useCases/transport/files/UploadOwnFile.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ class Validator extends SchemaValidator<UploadOwnFileValidatableRequest> {
4444
);
4545
}
4646

47-
if (input.content.length === 0) {
48-
validationResult.addFailure(
49-
new ValidationFailure(
50-
RuntimeErrors.general.invalidPropertyValue(`'${nameof<UploadOwnFileValidatableRequest>((r) => r.content)}' is empty`),
51-
nameof<UploadOwnFileValidatableRequest>((r) => r.content)
52-
)
53-
);
54-
}
55-
5647
if (input.expiresAt && CoreDate.from(input.expiresAt).isSameOrBefore(CoreDate.utc())) {
5748
validationResult.addFailure(
5849
new ValidationFailure(

packages/runtime/test/transport/files.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,19 @@ describe("File upload", () => {
6767
expect(file).toBeDefined();
6868

6969
const response = await transportServices1.files.downloadFile({ id: file.id });
70-
expect(response.isSuccess).toBeTruthy();
70+
expect(response).toBeSuccessful();
71+
7172
expect(response.value.content.byteLength).toBe(4);
7273
});
7374

74-
test("cannot upload an empty file", async () => {
75+
test("can exchange an empty file", async () => {
7576
const response = await transportServices1.files.uploadOwnFile(await makeUploadRequest({ content: Buffer.of() }));
76-
expect(response).toBeAnError("'content' is empty", "error.runtime.validation.invalidPropertyValue");
77+
expect(response).toBeSuccessful();
78+
79+
const downloadResponse = await transportServices1.files.downloadFile({ id: response.value.id });
80+
expect(downloadResponse).toBeSuccessful();
81+
82+
expect(downloadResponse.value.content.byteLength).toBe(0);
7783
});
7884

7985
test("cannot upload a file that is null", async () => {

0 commit comments

Comments
 (0)