[DEV] add mulktipart management
This commit is contained in:
parent
8e913b54ad
commit
db6a20fa02
@ -439,6 +439,9 @@ public class DataFactoryTsApi {
|
|||||||
if (MediaType.APPLICATION_JSON.equals(elem)) {
|
if (MediaType.APPLICATION_JSON.equals(elem)) {
|
||||||
builder.append("\n\t\t\t\tcontentType: HTTPMimeType.JSON,");
|
builder.append("\n\t\t\t\tcontentType: HTTPMimeType.JSON,");
|
||||||
break;
|
break;
|
||||||
|
} else if (MediaType.MULTIPART_FORM_DATA.equals(elem)) {
|
||||||
|
builder.append("\n\t\t\t\tcontentType: HTTPMimeType.MULTIPART,");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ export enum HTTPMimeType {
|
|||||||
IMAGE_PNG = 'image/png',
|
IMAGE_PNG = 'image/png',
|
||||||
JSON = 'application/json',
|
JSON = 'application/json',
|
||||||
OCTET_STREAM = 'application/octet-stream',
|
OCTET_STREAM = 'application/octet-stream',
|
||||||
|
MULTIPART = 'multipart/form-data',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RESTConfig {
|
export interface RESTConfig {
|
||||||
@ -119,6 +120,12 @@ export function RESTRequest({ restModel, restConfig, data, params, queries }: RE
|
|||||||
let body = data;
|
let body = data;
|
||||||
if (restModel.contentType === HTTPMimeType.JSON) {
|
if (restModel.contentType === HTTPMimeType.JSON) {
|
||||||
body = JSON.stringify(data);
|
body = JSON.stringify(data);
|
||||||
|
} else if (restModel.contentType === HTTPMimeType.MULTIPART) {
|
||||||
|
const formData = new FormData();
|
||||||
|
for (const name in data) {
|
||||||
|
formData.append(name, data[name]);
|
||||||
|
}
|
||||||
|
body = formData
|
||||||
}
|
}
|
||||||
console.log(`Call ${generateUrl}`)
|
console.log(`Call ${generateUrl}`)
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user