uploadfile options fix
gitea/salix/dev There was a failure building this commit
Details
gitea/salix/dev There was a failure building this commit
Details
This commit is contained in:
parent
e45d95ac10
commit
754640d552
|
@ -42,20 +42,21 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.uploadFile = async(ctx, options = {}) => {
|
Self.uploadFile = async(ctx, options) => {
|
||||||
const storageConnector = Self.app.dataSources.storage.connector;
|
const storageConnector = Self.app.dataSources.storage.connector;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const fileOptions = {};
|
const fileOptions = {};
|
||||||
const args = ctx.args;
|
const args = ctx.args;
|
||||||
|
|
||||||
let tx;
|
let tx;
|
||||||
|
let myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(options, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
if (!options.transaction) {
|
if (!myOptions.transaction) {
|
||||||
tx = await Self.beginTransaction({});
|
tx = await Self.beginTransaction({});
|
||||||
options.transaction = tx;
|
myOptions.transaction = tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -72,7 +73,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const addedDms = [];
|
const addedDms = [];
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const newDms = await createDms(ctx, file.name, options);
|
const newDms = await createDms(ctx, file.name, myOptions);
|
||||||
const pathHash = storageConnector.getPathHash(newDms.id);
|
const pathHash = storageConnector.getPathHash(newDms.id);
|
||||||
const container = await getContainer(pathHash);
|
const container = await getContainer(pathHash);
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function createDms(ctx, fileName, options) {
|
async function createDms(ctx, fileName, myOptions) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const storageConnector = Self.app.dataSources.storage.connector;
|
const storageConnector = Self.app.dataSources.storage.connector;
|
||||||
const myUserId = ctx.req.accessToken.userId;
|
const myUserId = ctx.req.accessToken.userId;
|
||||||
|
@ -107,12 +108,12 @@ module.exports = Self => {
|
||||||
reference: args.reference,
|
reference: args.reference,
|
||||||
description: args.description,
|
description: args.description,
|
||||||
hasFile: args.hasFile
|
hasFile: args.hasFile
|
||||||
}, options);
|
}, myOptions);
|
||||||
|
|
||||||
const extension = storageConnector.getFileExtension(fileName);
|
const extension = storageConnector.getFileExtension(fileName);
|
||||||
fileName = `${newDms.id}.${extension}`;
|
fileName = `${newDms.id}.${extension}`;
|
||||||
|
|
||||||
return newDms.updateAttribute('file', fileName, options);
|
return newDms.updateAttribute('file', fileName, myOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue