Spaces:
Running
on
Zero
Running
on
Zero
File size: 582 Bytes
f669ed4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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}`);
}
} |