Cannot download docx file submitted to google drive through google classroom - google-api

So when I submit a .docx file through google classroom it gets converted into a file with mimetype application/vnd.openxmlformats-officedocument.wordprocessingml.document and stored in the Classroom folder of the teacher's google drive.
I want to read the contents of this file so I can do analysis on them, but cannot find a suitable way to do this.
Initially, I tried using the google docs api
GET https://docs.googleapis.com/v1/documents/{documentId}
This threw an error that the mimetype was incorrect.
The google drive api for files/get allows me to get a download url for the document, but unfortunately this requires in browser authentication so I cannot make this work programmatically.
How shall I proceed to read the contents of this file?
I believe some possible solutions are converting the application/vnd.openxmlformats-officedocument.wordprocessingml.document mimetype into the standard google docs mimetype, or having a download url that doesnt require authentication, but I do not know how to do either of these!
Thanks in advance!

Related

Google Drive/Doc API Saving and Importing

My website currently creates a word document for users (docx format) and sends it to them as a downloadable so they can save it to their computer.
What I would like to know is if an Open in Google Doc "Button/Feature" exists. So instead of downloading the docx, the user could open it directly into their Google Drive and/or Google Doc account.
Is this possible?
Thanks,

Save uploaded files to Google Drive from website built on Ruby Volt

I'm building a web site using Ruby Volt for a publication. I'd like users to be able to upload images that will be stored on Google Drive. The Google Drive will belong to the publication, not to the site users who are uploading the images. If possible, I'd like the fact the images are being stored on Google Drive to be transparent to the site users.
The publication staff will access the images via their Google Drive.
My head is swimming with the Google documentation… Does anybody know if this is doable? If it is can you offer any pointers to example code or suggestions on how to get started?
So I can't help with the google drive API side of things, but in Volt, you can use a HttpController to post a input type="field". In the http controller, you can call params._field_name to get the data from rest. That will provide a tempfile you can copy out. Once I get time I'll make a demo app for file upload.

Transferring ownership of a specific Google Doc file using google-api-ruby-client

I'm looking to transfer ownership of a specific Google Docs file using the Google Apps API. There are many accounts on a single Google Apps domain. There are many files I would like to transfer so I do not want to do it manually.
In the UI I've only seen the ability to transfer ownership of all files from a particular user rather than individual files.
I've looked through the GitHub page for the google-api-ruby-client gem, but I was unable to come up with a solution. Can someone point me in the right direction or post an example?
You'll need to use the Google Drive API. Specifically the Permissions "update" method.
First find/get the File ID, using the Files.List method, which will allow you to search using a query. Then use the Permissions.Update (or Patch) method, making sure to set the transferOwnership parameter to True.
Full documentation is here: Google Drive API - Permissions

What are the file types in the file metadata ("exportLinks") in Google drive API?

I am developing a wrapper which called google drive api and retrieve exportLinks for the Google document in drive. I am trying to write a function to automatically identify the available links and assign to readable html href. So far, some of the type of files are :
application/pdf
application/rtf
application/vnd.oasis.opendocument.text
application/vnd.openxmlformats-officedocument.wordprocessingml.document
text/html
text/plain
I don't know how much there are and I want to know where I can find all type of files that Google Drive Api allow us to download.
Thanks!
As shown in the docs all possible mime types are allowed.
Accepted Media MIME types: */*

Is there a way to levearge Google Drive API to allow your application to create Google Docs from within your own system?

We were using an Iframe, then we started to use the API for Google Drive. We want to allow users to create a Google Doc from within our system w/o leaving our application. Does anyone know if this is possible?
Insert a new file with one of the Google Docs mimeTypes and wait for the response.
POST https://developers.google.com/drive/v2/reference/files/insert
{ "mimeType": "application/vnd.google-apps.document" }
Once response arrives, it'll contain an attribute called embedLink. Use embed link on iframe.
All available Google Docs mime types are on https://developers.google.com/drive/mime-types

Resources