Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async uploadPhoto(photo: any): Promise<{ photoLink: string, photoDeleteHash: string }> {
- if (!(/\.(gif|jpg|jpeg|png)$/i).test(extname(photo.originalname))) {
- throw new InvalidImageFormat();
- }
- const image = photo.buffer;
- const { data } = await axios(`${this.configService.photoStorageUrl}/upload`, {
- method: 'POST',
- headers: {
- 'Authorization': this.configService.clientId,
- 'Content-Type': 'multipart/form-data',
- },
- data: image,
- });
- return { photoLink: data.data.link, photoDeleteHash: data.data.deletehash };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement