Join Joseph Lowery for an in-depth discussion in this video Working with buckets, part of Google Cloud Storage and Data Essential Training.
- Buckets are the primary storage container in Google Cloud Storage. As covered in the first lesson the chapter, a bucket is located within a project, and itself contains the uploaded objects. I'll show you all you need to know about Google Cloud Storage buckets in this lesson. Now before we can start with the Google Cloud Storage buckets and objects, the service will have to be activated, which is automatic when you sign up for Google Cloud Platform currently. Should it ever become deactivated, I want to show you how to bring it back on.
So go to APIs & auth, click on APIs, and there you'll see Google Cloud Storage, and as you can see, it's currently on, and there's not a set quota here, they're very generous in that way, and of course, if you needed to reactivate it, you would just find it in the list down below, and it would be listed under Google Cloud Storage. Now, just heading back to the Overview page for my project, let's navigate now to Storage, Cloud Storage, and then Storage browser.
This will take us to Cloud Storage's web UI. And as the interface says, we're ready to create a bucket. So click that big blue button. Now perhaps the hardest thing about using buckets is naming them. Buckets must be unique across the entire Google Cloud Storage namespace. And, because they can appear in a DNS entry as part of a CNAME redirect, they have to conform to DNS naming conventions. And that means they have to between 3 and 63 characters long, they can only use lowercase letters and numbers and the underscore, dash, and period symbols.
Also, they have to start with a letter or a number, but they cannot begin with the prefix goog, G-O-O-G. See if you can figure out why that is. Okay. Got all that? Let's create our first bucket. In the dialog I'll enter lynda_gcs, Google Cloud Storage, _bucket_1. Now you won't be able to use that exact same name, so substitute your own unique variation.
And Google will let you know if it's not unique. Okay. Let me go ahead and click Create, and make sure mine is. Looks like I'm in. And as you can see, we're ready to upload files and start putting objects in our bucket. So I'll click Upload Files. Now when the files dialog appears, navigate to the Exercise Files folder, mine's on my desktop so I'll go there, and I'll go to Chapter 2, 02_04, open up the Start folder, and here I'm going to select pillars-of-creation.jpg.
This is a photo, let me go ahead and switch so you can see a little preview of it, that was recently released by NASA to celebrate the Hubble Telescope's 25 anniversary. It's an awesome, awesome photo. So I'm going to go ahead and click Open, and you can see the progress panel appear in the lower right. The upload happens pretty quickly, so as we can see it's already there, I'll close the activity monitor, and you can see that the file is listed within my bucket, pillars-of-creation.jpg.
Now let's go back, and this time we're going to choose the other option, Upload Folder. Now we're back at the Start folder, and this time I'm going to just choose gallery, and, now before I click the Upload button, let me just expand that a little bit so that you can see that there are four images inside of it, you can see a little bit of what they are. Now I could, if I wanted, select all the files within that folder, not with this dialog, but with the Upload Files one, but by going this route and selecting Upload Folder and then choosing the gallery folder, Cloud Storage will create this folder in my bucket and transfer all the files in a single operation.
So let me go ahead and click Upload, and you can see the images start to come in. We've got 2 of 4 done, 3 of 4, moving right along, you can see the gallery has been created, and my upload's complete. So now if I click on gallery, we'll drill down into that, and you can see the four images have been uploaded. You can click on any of the images though if you want to see it, click on the last one, and have that load, nice little abstract. Let's go back to the console.
Now you'll notice that the breadcrumb path up here has also changed. Of course, you don't always have to upload folders. So you can create them on the fly. Let's go back to the root of our bucket using the breadcrumb, and I'll click New Folder. I'm going to just call this one temp, and obviously there are no naming restrictions on creating folders. To upload a file to a folder, you have to be in that folder. That might seem obvious, but what's not obvious, if I go into temp here, is that you're actually using the Google Cloud Storage manager, which comes with full drag and drop capabilities.
To demonstrate, let me open up Finder, and don't show this yet, and I'll drill down, also shrink this down a little bit here, and I'll drill down into my Exercise Files, let's go into 02_04 again, and I'm going to bring in that pillars-of-creation.jpg and just drop it in. And now you can see that it's uploaded pretty quickly. Now let's go up a level. So as you can see, I now have two folders and a single file in my main bucket area.
I've created the temp folder manually, and dragged an object into it, but how do you get rid of something, a bucket that you no longer want? Well, you just select the folder, or the file's checkbox, depending on what level you're at, and once that's selected, Delete becomes active, I'll go ahead and press Delete, Google will ask for confirmation, and you can see that it shows you how many objects are in it and tells you that those will also be deleted, I'll go ahead and click OK, and it looks like we've already been successfully deleted, and my folder's now gone.
Now you can batch delete objects as well. Let's drill down into gallery, and if I wanted to remove, let's say, three images, I could select these here and then click Delete. In this case, I don't want to delete these, so I'll go ahead and hit Cancel. In the next lesson, we'll start to explore who gets to control these buckets and objects by taking a closer look at objects.
- Installing the Google Cloud SDK
- Working with buckets and objects
- Building a website with Cloud Storage
- Using Cloud SQL to manage data
- Setting up Cloud Datastore
- Exploring data with BigQuery
- Managing storage and data with Python