Node.js 空请求主体,文件从AngularJS通过ng流上载到Node/Express
我正在使用ng flow上传图片 我需要将上传设置为内容类型application/json: 但是怎么做呢 我的代码基于以下示例: 我猜它在标题配置中,但我猜。 这是我的$scope.image对象:Node.js 空请求主体,文件从AngularJS通过ng流上载到Node/Express,node.js,angularjs,express,flow-js,Node.js,Angularjs,Express,Flow Js,我正在使用ng flow上传图片 我需要将上传设置为内容类型application/json: 但是怎么做呢 我的代码基于以下示例: 我猜它在标题配置中,但我猜。 这是我的$scope.image对象: { image: { support: true supportDirectory: true files: [ { flowObj: { $ref: $ } file: { web
{
image: {
support: true
supportDirectory: true
files:
[ {
flowObj: {
$ref: $
}
file: {
webkitRelativePath:
lastModifiedDate: { }
name: super-phillip (1).gif
type: image/gif
size: 931802
}
name: super-phillip (1).gif
size: 931802
relativePath: super-phillip (1).gif
uniqueIdentifier: 931802-super-phillip1gif
chunks:
[ ]
paused: false
error: true
averageSpeed: 0
currentSpeed: 0
_lastProgressCallback: 1399049249446
_prevUploadedSize: 931802
_prevProgress: 0
} ]
defaults: {
chunkSize: 1048576
forceChunkSize: false
simultaneousUploads: 3
singleFile: false
fileParameterName: file
progressCallbacksInterval: 500
speedSmoothingFactor: 0.1
query: { }
headers: { }
withCredentials: false
preprocess: null
method: multipart
prioritizeFirstAndLastChunk: false
target: /
testChunks: true
generateUniqueIdentifier: null
maxChunkRetries: 0
chunkRetryInterval: null
permanentErrors:
[ 404, 415, 500, 501 ]
onDropStopPropagation: false
}
opts: {
chunkSize: 1048576
forceChunkSize: false
simultaneousUploads: 1
singleFile: true
fileParameterName: file
progressCallbacksInterval: 500
speedSmoothingFactor: 0.1
query: {
$ref: $["defaults"]["query"]
}
headers: {
$ref: $["defaults"]["headers"]
}
withCredentials: false
preprocess: null
method: multipart
prioritizeFirstAndLastChunk: false
target: ./upload
testChunks: true
generateUniqueIdentifier: null
maxChunkRetries: 3
chunkRetryInterval: 5000
permanentErrors:
[ 404, 501 ]
onDropStopPropagation: false
}
events: {
catchall:
[ null, null ]
}
onDrop: null
preventEvent: null
}
}
最新的express bodyParser()不再允许多部分formdata,因此您必须使用中间件,如connect multiparty或multer