Skip to content

Commit

Permalink
Drop gzipped option when uploading attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Oct 17, 2024
1 parent d68724e commit 88f3aa0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
3 changes: 0 additions & 3 deletions src/http/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ export default class Collection {
* @param {Number} [options.last_modified] The last_modified option.
* @param {Object} [options.permissions] The permissions option.
* @param {String} [options.filename] Force the attachment filename.
* @param {String} [options.gzipped] Force the attachment to be gzipped or not.
* @return {Promise<Object, Error>}
*/
@capable(["attachments"])
Expand All @@ -459,7 +458,6 @@ export default class Collection {
last_modified?: number;
permissions?: { [key in Permission]?: string[] };
filename?: string;
gzipped?: boolean;
} = {}
): Promise<
KintoResponse<{
Expand All @@ -477,7 +475,6 @@ export default class Collection {
{
last_modified,
filename: options.filename,
gzipped: options.gzipped,
headers: this._getHeaders(options),
safe: this._getSafe(options),
}
Expand Down
9 changes: 2 additions & 7 deletions src/http/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ interface RequestOptions {
safe?: boolean;
headers?: Headers | Record<string, string> | string[][];
method?: HttpMethod;
gzipped?: boolean | null;
last_modified?: number;
patch?: boolean;
}
Expand Down Expand Up @@ -159,19 +158,15 @@ export function addAttachmentRequest(
{ data, permissions }: RecordRequestBody = {},
options: AddAttachmentRequestOptions = {}
): KintoRequest {
const { headers, safe, gzipped } = { ...requestDefaults, ...options };
const { headers, safe } = { ...requestDefaults, ...options };
const { last_modified } = { ...data, ...options };

const body = { data, permissions };
const formData = createFormData(dataURI, body, options);

const customPath = `${path}${
gzipped !== null ? "?gzipped=" + (gzipped ? "true" : "false") : ""
}`;

return {
method: "POST",
path: customPath,
path,
headers: { ...headers, ...safeHeader(safe, last_modified) },
body: formData,
};
Expand Down
16 changes: 0 additions & 16 deletions test/http/requests_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,5 @@ describe("requests module", () => {
.to.have.property("If-Match")
.eql('"42"');
});

it("should support a gzipped option passed with true", () => {
expect(
requests.addAttachmentRequest("/foo", dataURL, {}, { gzipped: true })
)
.to.have.property("path")
.eql("/foo?gzipped=true");
});

it("should support a gzipped option passed with false", () => {
expect(
requests.addAttachmentRequest("/foo", dataURL, {}, { gzipped: false })
)
.to.have.property("path")
.eql("/foo?gzipped=false");
});
});
});

0 comments on commit 88f3aa0

Please sign in to comment.