Skip to content

Commit

Permalink
fixup: bucketName source + error if no key field
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Toozs committed Jul 9, 2024
1 parent e9a4300 commit 57f34b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,13 @@ const api = {

formDataParser.on('file', (fieldname, file, filename, encoding, mimetype) => {
fileEventData = { fieldname, file, filename, encoding, mimetype };
return next(null);
// no key field == error
if ('key' in request.formData) {
return next(null);
}
return next(errors.InvalidArgument.customizeDescription('Bucket POST must contain'
+ " a field named 'key'. If it is specified, please check the order of the fields."));
});

formDataParser.on('finish', () => {
// No file field == error
if (!fileEventData) {
Expand Down
6 changes: 4 additions & 2 deletions lib/api/objectPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ function objectPost(authInfo, request, streamingV4Params, log, callback) {
const {
headers,
method,
formData,
bucketName,
} = request;
let parsedContentLength = 0;
const passThroughStream = new PassThrough();
const requestType = request.apiMethods || 'objectPost';
const valParams = {
authInfo,
bucketName: request.formData.bucket,
objectKey: request.formData.key,
bucketName,
objectKey: formData.key,
requestType,
request,
};
Expand Down

0 comments on commit 57f34b9

Please sign in to comment.