Skip to content

Commit 5fe3f38

Browse files
authored
feat!: change default uploadFormat to 'raw' (#10424)
Switch the default upload format from 'multipart' to 'raw' binary uploads. BREAKING CHANGE: The default upload format has changed from 'multipart' to 'raw'. Existing applications that rely on multipart/form-data uploads must now explicitly set upload-format="multipart" to maintain the previous behavior.
1 parent 9dd60ab commit 5fe3f38

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

packages/upload/src/vaadin-upload-mixin.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ export declare class UploadMixinClass {
199199

200200
/**
201201
* Specifies the upload format to use when sending files to the server.
202-
* - 'multipart': Send file using multipart/form-data encoding (default)
203-
* - 'raw': Send file as raw binary data with the file's MIME type as Content-Type
202+
* - 'raw': Send file as raw binary data with the file's MIME type as Content-Type (default)
203+
* - 'multipart': Send file using multipart/form-data encoding
204204
* @attr {string} upload-format
205205
*/
206206
uploadFormat: UploadFormat;

packages/upload/src/vaadin-upload-mixin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,14 @@ export const UploadMixin = (superClass) =>
312312

313313
/**
314314
* Specifies the upload format to use when sending files to the server.
315-
* - 'multipart': Send file using multipart/form-data encoding (default)
316-
* - 'raw': Send file as raw binary data with the file's MIME type as Content-Type
315+
* - 'raw': Send file as raw binary data with the file's MIME type as Content-Type (default)
316+
* - 'multipart': Send file using multipart/form-data encoding
317317
* @attr {string} upload-format
318318
* @type {string}
319319
*/
320320
uploadFormat: {
321321
type: String,
322-
value: 'multipart',
322+
value: 'raw',
323323
},
324324

325325
/**

packages/upload/test/upload.test.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ describe('upload', () => {
156156
upload._uploadFile(file);
157157
});
158158

159-
it('should fire the upload-before with configurable form data name', (done) => {
159+
it('should fire the upload-before with configurable form data name in multipart mode', (done) => {
160+
upload.uploadFormat = 'multipart';
161+
160162
function MockFormData() {
161163
this.data = [];
162164
}
@@ -183,7 +185,9 @@ describe('upload', () => {
183185
window.FormData = OriginalFormData;
184186
});
185187

186-
it('should use formDataName property as a default form data name', (done) => {
188+
it('should use formDataName property as a default form data name in multipart mode', (done) => {
189+
upload.uploadFormat = 'multipart';
190+
187191
upload.addEventListener('upload-before', (e) => {
188192
expect(e.detail.file.formDataName).to.equal('attachment');
189193
done();
@@ -201,7 +205,9 @@ describe('upload', () => {
201205
expect(file.xhr.readyState).to.equal(0);
202206
});
203207

204-
it('should fire upload-request event', (done) => {
208+
it('should fire upload-request event in multipart mode', (done) => {
209+
upload.uploadFormat = 'multipart';
210+
205211
upload.addEventListener('upload-request', (e) => {
206212
expect(e.detail.file).to.be.ok;
207213
expect(e.detail.xhr).to.be.ok;
@@ -656,7 +662,7 @@ describe('upload', () => {
656662
expect(e.detail.xhr.status).to.equal(200);
657663
});
658664

659-
it('should include uploadFormat and requestBody in upload-request event for raw', (done) => {
665+
it('should include uploadFormat and requestBody in upload-request event in raw format', (done) => {
660666
upload.uploadFormat = 'raw';
661667
upload.addEventListener('upload-request', (e) => {
662668
expect(e.detail.uploadFormat).to.equal('raw');

0 commit comments

Comments
 (0)