Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
6f865a356f | |||
71a6ffef96 | |||
189916e62b | |||
33e36b5d44 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartrequest",
|
"name": "@pushrocks/smartrequest",
|
||||||
"version": "1.1.6",
|
"version": "1.1.8",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartrequest",
|
"name": "@pushrocks/smartrequest",
|
||||||
"version": "1.1.6",
|
"version": "1.1.8",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "dropin replacement for request",
|
"description": "dropin replacement for request",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -35,11 +35,13 @@ const appendFormField = async (
|
|||||||
formDataField: IFormField
|
formDataField: IFormField
|
||||||
) => {
|
) => {
|
||||||
if (formDataField.type === "filePath") {
|
if (formDataField.type === "filePath") {
|
||||||
formDataArg.append("type", "image");
|
let fileData = plugins.fs.readFileSync(
|
||||||
let fileData = plugins.fs.createReadStream(
|
|
||||||
plugins.path.join(process.cwd(), formDataField.payload)
|
plugins.path.join(process.cwd(), formDataField.payload)
|
||||||
);
|
);
|
||||||
formDataArg.append("media", fileData, "upload.pdf");
|
formDataArg.append("file", fileData, {
|
||||||
|
filename: 'upload.pdf',
|
||||||
|
contentType: 'application/pdf'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,5 +60,6 @@ export const postFormData = async (
|
|||||||
const requestOptions = Object.assign({}, optionsArg, { requestBody: form });
|
const requestOptions = Object.assign({}, optionsArg, { requestBody: form });
|
||||||
|
|
||||||
// lets fire the actual request for sending the formdata
|
// lets fire the actual request for sending the formdata
|
||||||
request(urlArg, requestOptions);
|
const response = await request(urlArg, requestOptions);
|
||||||
|
return response;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user