Ruby on Rails private link sharing: Google Docs Style
I would have a separate controller that uses a hash value to reference the event.
Something simple like the created_at + user_id hashed to create a unique reference.
You could also simply skip the check on a certain action but I would much prefer the first solution .
Access Google Drive API v3 with Ruby on Rails
You need OAuth 2.0 to authorize requests on the Drive API as described on the documentation. In that link, you can find: «All requests to the Drive API must be authorized by an authenticated user».
To complete that authorization process, you should follow the instructions on the Drive API Ruby Quickstart linked on your question. Generating and saving a credentials.json
for later use is the normal approach in this situation. Here you can read about using OAuth 2.0 over different scenarios.
I hope to have cleared your doubts on this topic, but feel free to ask further questions.
How to store private pictures and videos in Ruby on Rails
I would have Paperclip use S3 on the back-end, set uploaded files to private, and then use "Query String Request Authentication Alternative" to generate the URLs for my image tags.
http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?RESTAuthentication.html
How to download a file via the Google Drive API?
Stated in Download Files
Depending on the type of download you'd like to perform — a file, a Google Document, or a content link — you'll use one of the following URLs:You may go through the documentation for more information and examples.Downloading the file requires the user to have at least read access. Additionally, your app must be authorized with a scope that allows reading of file content.
- Download a file — files.get with
alt=media
file resource- Download and export a Google Doc — files.export
- Link a user to a file — webContentLink from the file resource
How to upload a file to a shared drive with Google API Drive v3 ruby gem
I believe your goal is as follows.
- You want to upload a file to the specific folder in the shared Drive using Drive API v3.
- You want to achieve this using googleaspif ro ruby.
Modified script:
google_file = Google::Apis::DriveV3::File.new(name: 'test.txt', parents: ['###'])
drive = Google::Apis::DriveV3::DriveService.new
drive.create_file(google_file, upload_source: "text.txt", supports_team_drives: true)
- Here, please set the folder ID to
###
ofparents: ['###']
. If you want to upload the file to the root folder of the shared Drive, please set the drive ID to###
ofparents: ['###']
.
Note:
- This modification suppoges that your
drive
can be used for uploading the file to the shared Drive. Please be careful about this.
References:
- Files: create
- Class: Google::Apis::DriveV3::DriveService
Related Topics
How to Find Out What Is Intercepting 'Method_Missing'
Watir Changing Mozilla Firefox Preferences
How to Avoid Circular Creation of Associated Models in Factory_Girl
Should I Move My Custom Methods to Model from Controller
Where Is Ruby's Erb Format "Officially" Defined
Rails: What's Wrong with This Multiple Join with Conditions on The Associations
Running Rails Console with Bundle Exec
How to Use The "Self" Keyword in Rails
Why Use Gemspec + Gemfile When Checking for Dependencies
How to Evaluate a Block Inside a Proc
One or More Params in Model Find Conditions with Ruby on Rails
Asynchronously Iterating Over The Response of a Request Using Thin and Sinatra
How to Use Reform to Prepopulate for Featured Objects