mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Now show missing file errors for multipart requests
This commit is contained in:
parent
6432a3cfc5
commit
7bf8edbc91
@ -14,9 +14,14 @@ export async function buildMultipart (params: Array<RequestBodyParameter>) {
|
||||
const lineBreak = '\r\n';
|
||||
let totalSize = 0;
|
||||
|
||||
async function addFile (path: string) {
|
||||
return new Promise(resolve => {
|
||||
const {size} = fs.statSync(path);
|
||||
function addFile (path: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let size;
|
||||
try {
|
||||
size = fs.statSync(path).size;
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
const stream = fs.createReadStream(path);
|
||||
stream.once('end', () => {
|
||||
resolve();
|
||||
@ -56,7 +61,11 @@ export async function buildMultipart (params: Array<RequestBodyParameter>) {
|
||||
addString(`Content-Type: ${contentType}`);
|
||||
addString(lineBreak);
|
||||
addString(lineBreak);
|
||||
await addFile(fileName);
|
||||
try {
|
||||
await addFile(fileName);
|
||||
} catch (err) {
|
||||
return reject(err);
|
||||
}
|
||||
} else {
|
||||
const name = param.name || '';
|
||||
const value = param.value || '';
|
||||
|
@ -22,7 +22,6 @@ describe('client_credentials', () => {
|
||||
}
|
||||
}));
|
||||
|
||||
// console.log('GET TOKEN', getToken);
|
||||
const result = await getToken(
|
||||
'req_1',
|
||||
ACCESS_TOKEN_URL,
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "insomnia",
|
||||
"version": "5.11.4",
|
||||
"version": "5.11.5",
|
||||
"productName": "Insomnia",
|
||||
"longName": "Insomnia REST Client",
|
||||
"description": "Debug APIs like a human, not a robot",
|
||||
|
Loading…
Reference in New Issue
Block a user