0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

CloudStorageからダウンロードしたファイルの中身を取得

Last updated at Posted at 2022-08-01

GCPのCloudStorageに設置されたバケット内にあるファイルの内容を取得する方法について説明します。
CloudSDKのライブラリを使用して以下のコードで取得が可能です。

Node.js
import { Storage } from '@google-cloud/storage';
const bucketName = 'test-qiita-bucket';
const fileName = 'test-file.txt';
storage = new Storage();
const data = await storage.bucket(bucketName).file(fileName).download();
const contents = data[0].toString();
console.log(contents);
出力(ファイル内容)
test1
test2

<参考ページ>
googleapis/nodejs-storage Public

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?