Skip to content

Commit 2036369

Browse files
committed
Only call getFileLocation if no url is provided
but use updated filename in getFileLocation
1 parent 0b79b20 commit 2036369

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Controllers/FilesController.js

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

32-
const defaultLocation = await this.adapter.getFileLocation(config, filename);
3332
const createResult = await this.adapter.createFile(filename, data, contentType, options, config);
33+
filename = createResult?.name || filename; // if createFile returns a new filename, use it
34+
35+
const url = createResult?.url || await this.adapter.getFileLocation(config, filename); // if createFile returns a new url, use it otherwise get the url from the adapter
36+
3437
return {
35-
url: createResult?.url || defaultLocation,
36-
name: createResult?.name || filename,
38+
url: url,
39+
name: filename,
3740
}
3841
}
3942

0 commit comments

Comments
 (0)