Reputation: 166
I'm looking to create a simple function to move a file from one bucket to another using app script. Also with the option to delete the original file. Does anyone already have a script that does this ?
Thanks, Ian
Upvotes: 0
Views: 1835
Reputation: 796
Searching for something similar, also ended up at mcpher's but too much code for simple things.
I ended up finding those resources which might be helpful:
You can use this a basis to set things up, then use the Cloud Storage API (JSON) for your needs.
Upvotes: 1
Reputation: 8112
Based from your encountered error, "could not find package", you may have missed installing the appropriate Cloud Client Library. Please check the installation instructions and reference material for the appropriate Cloud Client Library on your chosen Cloud API’s Client Libraries page.
You may also check Client Libraries Explained for more information regarding Cloud Storage Client Libraries.
Furthermore, you may want to follow the steps in moving your data from one bucket to another as discussed in Moving and Renaming Buckets which includes deleting the files from your old bucket.
Lastly, sample script is given in Upload Files to Google Cloud Storage with Google Scripts and discussed how to get started.
To get started, you need to go to the Google Developer’s console and enable the Google Cloud Storage API and the Google Cloud Storage JSON Data API. Also enable billing for your account to access Google Cloud Storage. Then create the API keys (OAuth 2, Web Application) with the redirect URL containing your Google Apps Script project key. The OAuth2 library for Apps Script should also be included in your project.
Upvotes: 0