LoginSignup
1
0

More than 3 years have passed since last update.

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

Posted at

やりたいこと

ある文字列のQRコードを作って、ストレージ上に配置する。

定義と実際に置く

const QRCode = require('qrcode');
const {Storage} = require('@google-cloud/storage');

const bucketName = 'bucket_name';
const storage = new Storage();
const bucket = storage.bucket(bucketName);


var filename ='shashin.png';
var filepath = path.join(os.tmpdir(), filename);
console.log(filepath);

await QRCode.toFile(filepath, 'QRにしたい文字列');

await storage
    .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);
    });
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0