Skip to content

Commit 0b79b20

Browse files
committed
Allow file adapter to override file name and location + give createFile access to config to allow getFileLocation calls internally
File adapter may specify a different filename or location during creation which should be returned after content storage. Example, adapter timestamps upload filenames. getFileLocation may result in a slightly different url than the one used to create the file. In the case where the url returned is identical this is not a problem. Additionally file adapter could call getFile location internally if it wanted to (and should probably have access to config for that reason)
1 parent 587abdd commit 0b79b20

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Controllers/FilesController.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ export class FilesController extends AdaptableController {
2929
filename = randomHexString(32) + '_' + filename;
3030
}
3131

32-
const location = await this.adapter.getFileLocation(config, filename);
33-
await this.adapter.createFile(filename, data, contentType, options);
32+
const defaultLocation = await this.adapter.getFileLocation(config, filename);
33+
const createResult = await this.adapter.createFile(filename, data, contentType, options, config);
3434
return {
35-
url: location,
36-
name: filename,
35+
url: createResult?.url || defaultLocation,
36+
name: createResult?.name || filename,
3737
}
3838
}
3939

0 commit comments

Comments
 (0)