Skip to content

Instantly share code, notes, and snippets.

@elibixby
Created August 18, 2016 17:48
Show Gist options
  • Save elibixby/2fefe460e0db957763093bbceb78106d to your computer and use it in GitHub Desktop.
Save elibixby/2fefe460e0db957763093bbceb78106d to your computer and use it in GitHub Desktop.
gcloud storage delete files
def delete_tmp_files(credentials, tmp_dir):
logging.info('Deleting temporary files')
parsed = urlparse.urlparse(tmp_dir)
client = storage.Client(credentials=credentials)
bucket = client.bucket(parsed.netloc)
batch = client.batch()
bucket.delete_blobs(bucket.list_blobs(prefix=parsed.path),
client=batch)
batch.finish()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment