Skip to content

Commit 57f34b9

Browse files
author
Will Toozs
committed
fixup: bucketName source + error if no key field
1 parent e9a4300 commit 57f34b9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/api/api.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,13 @@ const api = {
217217

218218
formDataParser.on('file', (fieldname, file, filename, encoding, mimetype) => {
219219
fileEventData = { fieldname, file, filename, encoding, mimetype };
220-
return next(null);
220+
// no key field == error
221+
if ('key' in request.formData) {
222+
return next(null);
223+
}
224+
return next(errors.InvalidArgument.customizeDescription('Bucket POST must contain'
225+
+ " a field named 'key'. If it is specified, please check the order of the fields."));
221226
});
222-
223227
formDataParser.on('finish', () => {
224228
// No file field == error
225229
if (!fileEventData) {

lib/api/objectPost.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,16 @@ function objectPost(authInfo, request, streamingV4Params, log, callback) {
3737
const {
3838
headers,
3939
method,
40+
formData,
41+
bucketName,
4042
} = request;
4143
let parsedContentLength = 0;
4244
const passThroughStream = new PassThrough();
4345
const requestType = request.apiMethods || 'objectPost';
4446
const valParams = {
4547
authInfo,
46-
bucketName: request.formData.bucket,
47-
objectKey: request.formData.key,
48+
bucketName,
49+
objectKey: formData.key,
4850
requestType,
4951
request,
5052
};

0 commit comments

Comments
 (0)