Created
May 6, 2019 17:58
-
-
Save stephenplusplus/82ad8615b7a7461c2426b7f33f9ae164 to your computer and use it in GitHub Desktop.
Revisions
-
stephenplusplus created this gist
May 6, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ 'use strict' const fs = require('fs-extra') const {Storage} = require('@google-cloud/storage') const gcs = new Storage() const bucket = gcs.bucket(process.env.BUCKET_NAME) const tmpFilePath = './tmp-file' const tmpItemFilePath = './tmp-item-file' const filePath = 'gissue-674--file' const itemFilePath = 'gissue-674--item' const uploadTmpFilePromise = fs .outputFile(tmpFilePath, 'tmp-file contents') .then(() => bucket.upload(tmpFilePath, {destination: filePath})) const uploadTmpItemFilePromise = fs .outputFile(tmpItemFilePath, 'tmp-item-file contents') .then(() => bucket.upload(tmpItemFilePath, {destination: itemFilePath})) Promise .all([uploadTmpFilePromise, uploadTmpItemFilePromise]) .then(() => bucket.file(itemFilePath).exists()) .then(() => console.log('done!'), console.error) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ { "name": "gissue-674", "version": "1.0.0", "description": "", "main": "index.js", "keywords": [], "author": "", "dependencies": { "@google-cloud/storage": "^2.5.0", "fs-extra": "^7.0.1" } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ https://github.com/googleapis/nodejs-storage/issues/674