Skip to content

Commit 85b8636

Browse files
committed
[REF]: change merge default config instead of choosing when config is not provided
1 parent d23cfac commit 85b8636

File tree

7 files changed

+31
-29
lines changed

7 files changed

+31
-29
lines changed

build/components/dropzone/components/utils/dropzone-ui.upload.utils.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { DropzoneProps } from "../Dropzone/DropzoneProps";
22
import { FileValidated } from "./validation.utils";
3+
export declare const DEFAULT_CONFIG: {
4+
headers: {
5+
"content-type": string;
6+
};
7+
};
38
export declare const uploadPromiseAxios: (file: FileValidated, url: string, method: DropzoneProps["method"], config: any) => Promise<UploadPromiseAxiosResponse>;
49
export interface UploadPromiseAxiosResponse {
510
serverResponse: FileDuiResponse;

build/index.es.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/index.es.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/index.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dropzone-ui/react",
3-
"version": "6.5.1",
3+
"version": "6.5.2",
44
"description": "The best and most complete React library for managing file uploads. Multilanguage support. Server side support. Material design styles. Code generator on webpage.",
55
"main": "./build/index.js",
66
"module": "./build/index.es.js",
@@ -12,14 +12,15 @@
1212
"keywords": [
1313
"dropzone",
1414
"react-dropzone",
15-
"material-ui",
16-
"dropzone-ui",
17-
"material",
1815
"file upload",
1916
"file",
2017
"upload",
2118
"react-component",
2219
"react",
20+
"ui",
21+
"material-ui",
22+
"dropzone-ui",
23+
"material",
2324
"drag",
2425
"drop",
2526
"mui",
@@ -63,8 +64,6 @@
6364
"@types/testing-library__react": "^10.2.0",
6465
"@typescript-eslint/eslint-plugin": "^5.9.0",
6566
"@typescript-eslint/parser": "^5.9.0",
66-
"ansi-regex": "^6.0.1",
67-
"ansi-html": "^0.0.7",
6867
"babel-loader": "^8.2.3",
6968
"coveralls": "^3.1.0",
7069
"css-loader": "^6.5.1",
@@ -73,9 +72,6 @@
7372
"eslint-plugin-jest": "^25.3.4",
7473
"eslint-plugin-prettier": "^4.0.0",
7574
"eslint-plugin-react": "^7.27.1",
76-
"fork-ts-checker-webpack-plugin": "^6.5.0",
77-
"identity-obj-proxy": "^3.0.0",
78-
"immer": "^9.0.7",
7975
"jest": "^27.4.7",
8076
"json-schema": "0.4.0",
8177
"prettier": "^2.5.1",
@@ -87,9 +83,7 @@
8783
"rollup-plugin-terser": "^7.0.2",
8884
"rollup-plugin-typescript2": "^0.31.1",
8985
"sass-loader": "^12.4.0",
90-
"set-value": "^4.0.1",
9186
"style-loader": "^3.3.1",
92-
"trim": "^1.0.1",
9387
"ts-jest": "^27.1.2",
9488
"ts-loader": "^9.2.5",
9589
"tslib": "^2.1.0",

src/components/dropzone/components/utils/dropzone-ui.upload.utils.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import axios from "axios";
1+
import axios, { AxiosResponse } from "axios";
22
import { DropzoneProps } from "../Dropzone/DropzoneProps";
33
import { FileValidated, UPLOADSTATUS } from "./validation.utils";
4-
4+
export const DEFAULT_CONFIG = {
5+
headers: {
6+
"content-type": "multipart/form-data;",
7+
},
8+
};
59
export const uploadPromiseAxios = async (
610
file: FileValidated,
711
url: string,
@@ -13,16 +17,15 @@ export const uploadPromiseAxios = async (
1317
try {
1418
const localMethod: DropzoneProps["method"] = method || "POST";
1519
const fileToUpload: File = file.file;
16-
const formData = new FormData();
20+
const formData: FormData = new FormData();
1721
formData.append("file", fileToUpload);
22+
1823
const configParams =
19-
config ||
20-
{
21-
headers: {
22-
"content-type": "multipart/form-data;",
23-
},
24-
};
25-
let response;//= { data: {} };// await axios.post(url, formData, configParams);
24+
config ? {
25+
...config, ...DEFAULT_CONFIG
26+
} : DEFAULT_CONFIG;
27+
let response: AxiosResponse<any, any>;//= { data: {} };// await axios.post(url, formData, configParams);
28+
2629
switch (localMethod) {
2730
case "POST": response = await axios.post(url, formData, configParams); break;
2831
case "PATCH": response = await axios.patch(url, formData, configParams); break;

0 commit comments

Comments
 (0)