mirror of
https://github.com/plankanban/planka.git
synced 2025-07-20 05:39:43 +02:00
parent
ad7fb51cfa
commit
2ee1166747
1557 changed files with 76832 additions and 47042 deletions
|
@ -1,21 +1,17 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
const util = require('util');
|
||||
const { v4: uuid } = require('uuid');
|
||||
|
||||
async function doUpload(paramName, req, options) {
|
||||
const uploadOptions = {
|
||||
...options,
|
||||
dirname: options.dirname || sails.config.custom.uploadsTempPath,
|
||||
};
|
||||
const upload = util.promisify((opts, callback) => {
|
||||
return req.file(paramName).upload(opts, (error, files) => callback(error, files));
|
||||
});
|
||||
return upload(uploadOptions);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
friendlyName: 'Receive uploaded file from request',
|
||||
|
||||
description:
|
||||
"Store a file uploaded from a MIME-multipart request part. The request part name must be 'file'; the resulting file will have a unique UUID-based name with the same extension.",
|
||||
'Store a file uploaded from a MIME-multipart request part. The resulting file will have a unique UUID-based name with the same extension.',
|
||||
|
||||
inputs: {
|
||||
paramName: {
|
||||
type: 'string',
|
||||
|
@ -29,11 +25,15 @@ module.exports = {
|
|||
},
|
||||
},
|
||||
|
||||
fn: async function modFn(inputs, exits) {
|
||||
exits.success(
|
||||
await doUpload(inputs.paramName, inputs.req, {
|
||||
saveAs: uuid(),
|
||||
async fn(inputs, exits) {
|
||||
const upload = util.promisify((options, callback) =>
|
||||
inputs.req.file(inputs.paramName).upload(options, (error, files) => callback(error, files)),
|
||||
);
|
||||
|
||||
return exits.success(
|
||||
await upload({
|
||||
dirname: sails.config.custom.uploadsTempPath,
|
||||
saveAs: uuid(),
|
||||
maxBytes: null,
|
||||
}),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue