Skip to content

Commit

Permalink
Merge pull request #1712 from Inist-CNRS/fix/upload-file-tenant
Browse files Browse the repository at this point in the history
Fix(tenant): Add tenant name in path for upload file
  • Loading branch information
arimet authored Sep 26, 2023
2 parents 7d67176 + a118229 commit 37fd6dd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion globalConfig.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"mongoUri":"mongodb://127.0.0.1:36595/jest?","mongoDBName":"jest"}
{"mongoUri":"mongodb://127.0.0.1:43217/jest?","mongoDBName":"jest"}
8 changes: 4 additions & 4 deletions src/api/controller/api/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export const parseRequest = async (ctx, loaderName, next) => {
totalChunks: parseInt(resumableTotalChunks, 10),
totalSize: parseInt(resumableTotalSize, 10),
currentChunkSize: parseInt(resumableCurrentChunkSize, 10),
filename: `${config.uploadDir}/${resumableIdentifier}`,
filename: `${config.uploadDir}/${ctx.tenant}_${resumableIdentifier}`,
extension,
chunkname: `${config.uploadDir}/${resumableIdentifier}.${chunkNumber}`,
chunkname: `${config.uploadDir}/${ctx.tenant}_${resumableIdentifier}.${chunkNumber}`,
stream,
customLoader: loaderName === 'custom-loader' ? customLoader : null,
};
Expand Down Expand Up @@ -168,8 +168,8 @@ export const checkChunkMiddleware = async (ctx, loaderName) => {
const chunkNumber = parseInt(resumableChunkNumber, 10);
const totalChunks = parseInt(resumableTotalChunks, 10);
const currentChunkSize = parseInt(resumableCurrentChunkSize, 10);
const filename = `${config.uploadDir}/${resumableIdentifier}`;
const chunkname = `${config.uploadDir}/${resumableIdentifier}.${resumableChunkNumber}`;
const filename = `${config.uploadDir}/${ctx.tenant}_${resumableIdentifier}`;
const chunkname = `${config.uploadDir}/${ctx.tenant}_${resumableIdentifier}.${resumableChunkNumber}`;
const [extension] = resumableFilename.match(/[^.]*$/);

const exists = await checkFileExists(chunkname, currentChunkSize);
Expand Down
4 changes: 2 additions & 2 deletions src/api/controller/api/upload.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ describe('upload', () => {
expect(next).toHaveBeenCalled();
expect(ctx.resumable).toEqual({
stream: 'stream',
filename: `${config.uploadDir}/identifier`,
chunkname: `${config.uploadDir}/identifier.10`,
filename: `${config.uploadDir}/lodex_test_identifier`,
chunkname: `${config.uploadDir}/lodex_test_identifier.10`,
totalChunks: 100,
totalSize: 500,
currentChunkSize: 5,
Expand Down

0 comments on commit 37fd6dd

Please sign in to comment.