Now show missing file errors for multipart requests

This commit is contained in:
Gregory Schier 2017-11-10 18:30:09 +01:00
parent 6432a3cfc5
commit 7bf8edbc91
3 changed files with 14 additions and 6 deletions

View File

@ -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 || '';

View File

@ -22,7 +22,6 @@ describe('client_credentials', () => {
}
}));
// console.log('GET TOKEN', getToken);
const result = await getToken(
'req_1',
ACCESS_TOKEN_URL,

View File

@ -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",