Severin
Severin

Reputation: 8588

Get Filepath from uploaded file on Google Cloud Storage

I just configured my application to use Google Cloud Storage for storing user uploads. So far I was able to retrieve the file path of an uploaded by doing so:

ActiveStorage::Blob.service.send(:path_for, file.key)

However, on Google Cloud Storage this gives me the following error:

NoMethodError (undefined method `path_for' for #<ActiveStorage::Service::GCSService:...>)

How can I retrieve the filepath here?

Upvotes: 0

Views: 681

Answers (1)

Kunal Deo
Kunal Deo

Reputation: 2298

You can use url_for_direct_upload(key, expires_in:, checksum:, **) or url(key, expires_in:, filename:, content_type:, disposition:) to get the GCS urls.

Reference

Upvotes: 1

Related Questions