Skip to content

Commit

Permalink
FIO-9207: Fix image preview for file component when using google drive
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinanciani committed Jan 22, 2025
1 parent fe540f4 commit aea85eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/file/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ export default class FileComponent extends Field {
if (this.component.privateDownload) {
fileInfo.private = true;
}
return this.fileService.downloadFile(fileInfo).then((result) => result.url);
// pass the component to the downloadFile method
return this.fileService.downloadFile(fileInfo, this.component).then((result) => result.url);
}

get emptyValue() {
Expand Down
5 changes: 3 additions & 2 deletions src/providers/storage/googleDrive.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ function googledrive(formio) {
xhr.send(fd);
}));
},
downloadFile(file) {
downloadFile(file, component) {
const token = formio.getToken();
// Constructed the url with the fileId, fileName, displayImage, imageSize if applicable
file.url =
`${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}`;
`${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}${component.image ? '&displayImage=true' : ''}${component.imageSize ? `&imageSize=${component.imageSize}` : ''}`;
return Promise.resolve(file);
},
deleteFile: function deleteFile(fileInfo) {
Expand Down

0 comments on commit aea85eb

Please sign in to comment.