Skip to content

Commit

Permalink
#3060-removed finance get image
Browse files Browse the repository at this point in the history
  • Loading branch information
caiodasilva2005 committed Dec 20, 2024
1 parent 2722e7d commit b9206bd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/backend/src/controllers/onboarding.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export default class OnboardingController {
static async downloadImage(req: Request, res: Response, next: NextFunction) {
try {
const { fileId } = req.params;
console.log('FILE ID:', fileId);

const imageData = await OnboardingServices.downloadImage(fileId);

Expand Down
1 change: 0 additions & 1 deletion src/frontend/src/apis/onboarding.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const downloadGoogleImage = async (fileId: string): Promise<Blob> => {
const response = await axios.get(apiUrls.imageById(fileId), {
responseType: 'arraybuffer' // Set the response type to 'arraybuffer' to receive the image as a Buffer
});
console.log('ID IN API:', fileId);
const imageBuffer = new Uint8Array(response.data);
const imageBlob = new Blob([imageBuffer], { type: response.headers['content-type'] });
return imageBlob;
Expand Down
15 changes: 15 additions & 0 deletions src/frontend/src/apis/organizations.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,18 @@ export const setOrganizationFeaturedProjects = async (featuredProjectIds: string
projectIds: featuredProjectIds
});
};

/**
* Downloads a given fileId from google drive into a blob
*
* @param fileId the google id of the file to download
* @returns the downloaded file as a Blob
*/
export const downloadGoogleImage = async (fileId: string): Promise<Blob> => {
const response = await axios.get(apiUrls.imageById(fileId), {
responseType: 'arraybuffer' // Set the response type to 'arraybuffer' to receive the image as a Buffer
});
const imageBuffer = new Uint8Array(response.data);
const imageBlob = new Blob([imageBuffer], { type: response.headers['content-type'] });
return imageBlob;
};
2 changes: 1 addition & 1 deletion src/frontend/src/hooks/organizations.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
setOrganizationLogo,
setOrganizationFeaturedProjects
} from '../apis/organizations.api';
import { downloadGoogleImage } from '../apis/onboarding.api';
import { downloadGoogleImage } from '../apis/organizations.api';

interface OrganizationProvider {
organizationId: string;
Expand Down

0 comments on commit b9206bd

Please sign in to comment.