Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-upload

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-upload - npm Package Compare versions

Comparing version 1.0.5 to 1.0.7

test/mocha.opts

29

index.js

@@ -5,23 +5,28 @@ 'use strict';

const FormData = require('form-data');
const fs = require('fs');
const contentType = 'content-type';
const isObject = (obj) => {
return typeof obj === "object" && obj !== null;
}
return typeof obj === 'object' && obj !== null;
};
const API = axios.create();
const instance = axios.create();
API.interceptors.request.use((config) => {
instance.interceptors.request.use((config) => {
const formData = config.data;
const data = config.data;
if (isObject(formData)) {
if (isObject(data)) {
config.maxContentLength || (config.maxContentLength = 1024 * 1024 * 100);
config.transformRequest = [(data, headers) => {
let form = new FormData();
for(let key in formData) {
form.append(key, formData[key]);
for (let key in data) {
if (data.hasOwnProperty(key)) {
form.append(key, data[key]);
}
}
headers[contentType] = form.getHeaders()[contentType];
delete headers.post['Content-Type'];
delete headers.put['Content-Type'];
delete headers.patch['Content-Type'];
Object.assign(headers, form.getHeaders());
return form;

@@ -36,2 +41,2 @@ }];

module.exports = API;
module.exports = instance;
{
"name": "axios-upload",
"version": "1.0.5",
"version": "1.0.7",
"description": "axios upload formdata",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "./node_modules/.bin/mocha"
},

@@ -15,7 +15,6 @@ "repository": {

"axios",
"upload",
"formdata"
],
"author": "jiayufeng",
"license": "ISC",
"license": "MIT",
"bugs": {

@@ -28,3 +27,8 @@ "url": "https://github.com/JYFiaueng/axios-upload/issues"

"form-data": "^2.3.2"
},
"devDependencies": {
"@zhike/koa2-upload": "^1.0.0",
"koa": "^2.5.1",
"mocha": "^5.2.0"
}
}

@@ -22,2 +22,3 @@ ## axios-upload

// 这里直接将 stream 传入即可
// 文件默认上传最大为100M,若需修改,使用maxContentLength参数,单位byte
const data = {

@@ -24,0 +25,0 @@ name: 'test',

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc