Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8896

QRを作ってストレージに置く。

$
0
0

やりたいこと

ある文字列の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);});

Viewing all articles
Browse latest Browse all 8896

Trending Articles