sagar verma
sagar verma

Reputation: 432

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.

Upvotes: 0

Views: 763

Answers (2)

mechnicov
mechnicov

Reputation: 15298

You tagged question with ruby-on-rails-3

Old rails versions use uploaders like carrierwave

It's possible to use it to upload files to GCS

You can upload not only local files using this gem but also from remote URL, just use special attribute

Upvotes: 1

DazWilkin
DazWilkin

Reputation: 40251

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.

Upvotes: 2

Related Questions