feat: upload profile picture from google (#964)

* feat: upload profile picture from google

* fix: only add profile picture if user don't have any
This commit is contained in:
Jérémy M
2023-07-27 18:06:50 +02:00
committed by GitHub
parent 52399d4dde
commit 58530be78b
6 changed files with 113 additions and 6 deletions

View File

@ -1,3 +1,5 @@
import axios from 'axios';
const cropRegex = /([w|h])([0-9]+)/;
export type ShortCropSize = `${'w' | 'h'}${number}` | 'original';
@ -19,3 +21,11 @@ export const getCropSize = (value: ShortCropSize): CropSize | null => {
value: +match[2],
};
};
export const getImageBufferFromUrl = async (url: string): Promise<Buffer> => {
const response = await axios.get(url, {
responseType: 'arraybuffer',
});
return Buffer.from(response.data, 'binary');
};