STIKO
STIKO

Reputation: 2095

How to get file content and move file to different Google Cloud Storage using Google Cloud functions

I'm trying to get the file that was uploaded to Google Cloud Storage, do some work with its content, and move it to a different bucket using Google Cloud Functions with python3.7. Following their documentation I was only able to get file name. I tried using import cloudstorage but it errors module 'cloudstorage' has no attribute 'NotFoundError', and googling did not get me anywhere.

Does any one have a sample code that could do what I need?

Upvotes: 0

Views: 222

Answers (1)

Mangu
Mangu

Reputation: 3325

The cloudstorage library is specific to the Standard environment of App Engine.

A library compatible with Cloud Storage would be google-cloud-storage. You must declare it in your requirements.txt file for your function.

This example on how to copy from one bucket to another should suffice. After copying it, you can just do source_blob.delete() to get rid of it.

Upvotes: 1

Related Questions