I want to use Google cloud storage in my next project. My aim is tracking various web sites and collecting some photos. As, I read the documentation for gsutil; I'm able download the file manually to my server and upload it google cloud storage by using gsutil.
Downloading and uploading files generates so much traffic in my server. Are there a way to let google cloud download file direct from http?
How to Download File Directly to Online Storage Usually? For downloaing files to cloud storage, you can first of all download and save them to local disk and then upload them from local to cloud storage. As for downloading directly to cloud, you can turn to the third party tool such as MultCloud for help.
Uploading files to Google Cloud Storage from a URL is possible, but there are a few things to keep in mind. First, you'll need to create a Google Cloud Storage bucket and give it a name. Next, you'll need to create a file object in the bucket and provide the URL of the file you want to upload.
In your Cloud Shell Editor Explorer, right-click a directory or file and then click Copy Download Link, Download, or Upload Files. Alternatively, you can navigate to File > Download/Upload Files.
This is very easy to do from the Google Cloud Shell. Seems to work for all file sizes:
curl http://speedtest.tele2.net/10GB.zip | gsutil cp - gs://YOUR_BUCKET_NAME/10GB.zip
Basically curl streams the data directly to the bucket.
Original approach: This works as long as your download is less than ~ 4.6 GB. Launch the Cloud Shell (first icon on your top right after you login to your project in GCP) and use wget to download the file you want. For instance, to download 7-Zip type:
wget https://www.7-zip.org/a/7z1805-x64.exe
Now with the file in your Cloud Shell user home you can copy it to a Google Cloud Storage bucket using the gsutil command:
gsutil cp ./7z1805-x64.exe gs://your_bucket_name/
If the file is bigger than 4.6 GB you can still do it but you need to mount the bucket in your Cloud Shell using gcsfuse:
Create a directory in your Cloud Shell user home
mkdir ~/mybucket
Now mount your bucket in that directory using gcsfuse:
gcsfuse bucket_name ~/mybucket
Change the current directory to mount point directory:
cd mybucket
(if you want to have some fun run "df -h ." to see how much space you got in that mount point)
Now use wget to get the file directly into your bucket (sample using 10GB file off the web):
wget https://speed.hetzner.de/10GB.bin
Google Cloud Storage only accepts data directly. There's no way to pass it a URL and have it save the contents as an object.
However, there's no reason you couldn't build this functionality yourself. For example, you could set up one or more dedicated GCE instanceS that would load URLs and then save them to GCS. Google doesn't charge for network ingress into GCE or for from GCE into GCS within a region, either, which helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With