Created
May 6, 2019 17:58
-
-
Save stephenplusplus/82ad8615b7a7461c2426b7f33f9ae164 to your computer and use it in GitHub Desktop.
@google-cloud/storage Issue 674
This file contains 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 characters
'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 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 characters
{ | |
"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" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment