kenken999's picture
df
f669ed4
raw
history blame
582 Bytes
import { Drive } from '@google-cloud/drive';
import { doPost } from './LineMock';
const drive = new Drive();
export class LineImageSaver {
doPost(e: any) {
const imageData = e.postData.contents;
this.saveImageToDrive(imageData);
}
saveImageToDrive(imageData: string) {
const file = drive.files.insert({
resource: {
title: 'Line Image',
mimeType: 'image/jpeg',
},
media: {
mimeType: 'image/jpeg',
body: Buffer.from(imageData, 'base64'),
},
});
console.log(`Image saved to Drive: ${file.id}`);
}
}