Home > database >  upload file to google bucket from remote url in ruby
upload file to google bucket from remote url in ruby

Time:07-07

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.

CodePudding user response:

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.

CodePudding user response:

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

  • Related