Google Storage
Google Storage allows to store any amount of data in Google Cloud Buckets and access it whenever is needed

Credential configuration
This credential configuration is done with a single JSON that looks like this:
{
"projectId": "PROJECT_ID",
"credentials": {
"type": "service_account",
"project_id": "PROJECT_ID",
"private_key_id": "KEY_ID",
"private_key": "-----BEGIN PRIVATE KEY-----\nPRIVATE_KEY\n-----END PRIVATE KEY-----\n",
"client_email": "SERVICE_ACCOUNT_EMAIL",
"client_id": "CLIENT_ID",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/SERVICE_ACCOUNT_EMAIL"
}
}
The projectId
corresponds to the project ID from the Google Developer's Console.
The credentials
field of the JSON corresponds to a JSON key of the service account. This key
is downloaded as a JSON file when you create it. You only need to paste its content inside credentials field.
If you don't have one, create a service account and then,
a JSON key for that service account.
The service account which you use needs permissions to access BigQuery to work properly.
Here you have an example of a filled credential configuration form in YepCode:

Google Store snippets available in editor
The title is the triggering text for YepCode to autocomplete the script
Integration
const googleStorageClient = yepcode.integration.googleStorage(credentialSlug);
const { Storage } = require("@google-cloud/storage");
const googleStorageCredentials = {
projectId: "YepCode",
credentials: {
type: "service_account",
project_id: "yepcode",
private_key_id: "XXXXX",
private_key: \`-----BEGIN PRIVATE KEY-----\nx\n-----END PRIVATE KEY-----\`,
client_email: "yepcode@example.org",
client_id: "1234567890",
auth_uri: "https://example.org",
token_uri: "https://example.org",
auth_provider_x509_cert_url: "https://example.org",
client_x509_cert_url: "https://example.org",
}
};
const googleStorage = new Storage(googleStorageCredentials);
Create a new bucket
async function createBucket() {
await googleStorageClient.createBucket(bucketName);
}
createBucket().catch(console.error);
Create a notification
async function createNotification() {
await googleStorageClient.bucket(bucketName).createNotification(notificationTopic);
}
createNotification().catch(console.error);
Delete a bucket
async function deleteBucket() {
await googleStorageClient.bucket(bucketName).delete();
}
deleteBucket().catch(console.error);
Delete a notification
async function deleteNotification() {
await googleStorageClient.bucket(bucketName).notification(notificationId).delete();
}
deleteNotification().catch(console.error);
List buckets
async function listBuckets() {
const [buckets] = await googleStorageClient.getBuckets();
buckets.forEach(bucket => {
console.log(bucket.name);
});
}
listBuckets().catch(console.error);
List notifications
async function listNotifications() {
const [notifications] = await googleStorageClient.bucket(bucketName).getNotifications();
notifications.forEach(notification => {
console.log(notification.id);
});
}
listNotifications().catch(console.error);
Upload a file
async function uploadFile() {
await googleStorageClient.bucket(bucketName).upload(filePath, {
destination: destinationFileName,
});
}
uploadFile().catch(console.error);
Download a file
async function downloadFile() {
const options = {
destination: {1:destinationFileName},
};
await googleStorageClient.bucket(bucketName).file(fileName).download(options);
}
downloadFile().catch(console.error);
Delete a file
async function deleteFile() {
await storage.bucket(bucketName).file(fileName).delete();
}
deleteFile().catch(console.error);