Search code examples
rubyruby-on-rails-3google-cloud-platformfile-uploadgoogle-cloud-storage

upload file to google bucket from remote url in ruby


We have found various solutions around upload the file to google cloud bucket from local system. However I am wondering if is there a way we can upload file to bucket using the public URL or link.

https://googleapis.dev/ruby/google-cloud-storage/latest/index.html

I want to upload a file from remote url to GCS bucket via ruby code. Any suggestion here would be really appreciated.


Solution

  • Your code sits between the remote URL and the Google Cloud Storage (GCS) Bucket.

    You've 2 alternatives:

    1. (As you describe) Download the file behind the remote URL to a file system accessible to your code and then upload it to GCS;
    2. Stream the file from the remote location into memory (you'll need to write this) and then (using GCS client library) stream the file into a GCS object.