やりたいこと
ある文字列のQRコードを作って、ストレージ上に配置する。
定義と実際に置く
constQRCode=require('qrcode');const{Storage}=require('@google-cloud/storage');constbucketName='bucket_name';conststorage=newStorage();constbucket=storage.bucket(bucketName);varfilename='shashin.png';varfilepath=path.join(os.tmpdir(),filename);console.log(filepath);awaitQRCode.toFile(filepath,'QRにしたい文字列');awaitstorage.bucket(bucketName).upload(filepath,{gzip:false}).then(res=>{console.log(res[0].metadata);console.log(`${filename} uploaded to ${bucketName}.`);}).catch(err=>{console.error('ERROR:',err);});