Google Picker API hide native google drive workspace formats - google-drive-api

In Google Drive a user can create a new Google Doc/Sheet/Slide/Form etc as a Drive native format. Is there a way to hide these types of files when using the Drive Picker API? I want the user to only see files they have uploaded (or have had shared with them) and not created in Drive.
For example, if I add a view to the picker with ViewId.DOCUMENTS, then everything from Google Doc, txt, and docx show up. Just haven't found away to filter out the Google Doc mime type.

Have you tried using setMimeTypes? Use it to specify what format do you want to be included.
Code:
var view = new google.picker.View(google.picker.ViewId.DOCS);
// include only txt and docx files
view.setMimeTypes("text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document");
var picker = new google.picker.PickerBuilder()
.addView(view)
Output:
Note:
Drive picker was made for google drive. So it's natural to only have Views supporting its native file types.
What's good is that Google provided us a way of specifying file types not included in their views via setMimeTypes
Currently, I don't find any methods in excluding a certain mime type or view
Additionally, you can try setQuery. I tested this a bit and it seems view.setQuery("*.docx|*.txt") will result in all docx and txt files (in my case). You can combine this with or choose it over setMimeTypes. Just test it out to see what solution fits you.
Reference:
Picker

Related

How to get the filesize of document from Doc Picker

I am using the Picker Class (https://developers.google.com/picker/docs/reference#configuration-classes-and-types) to allow users to upload files from their Google Drive account.
I can get various properties of what they've selected, but I cannot seem to be able to get the file size;
eg;
var doc = data[google.picker.Response.DOCUMENTS][0];
url = doc[google.picker.Document.URL];
var name = doc[google.picker.Document.NAME];
var size = ??? [how-to-get-document-file-size]
Using the property name fileSize, as given in Drive REST API v2 - Files, can be used but is only populated for files with content stored in Drive. It is not populated for Google Docs or shortcut files.
I tried to look for ways on how to get file size too, but it seems that it is currently not available. Google Drive SDK currently do not provide the size of a file created within Google doc and found this SO post - Retrieve a “Google doc” created file size with the google drive api for ios which is somehow related to your concern.

Is it possible to covert Word docs to a Google Doc?

I am uploading Word documents to Google Drive using the Google SDK. I can view these files once uploaded through the Google Drive interface, but to edit these documents I need to selected "Open with Google Docs". When I do this, Google makes another version of the file and saves it to my Google Drive.
I want to automatically create a URL for users to click on once their file has been uploaded, so I presume I somehow need to convert the uploaded file (Word Document) to a Google Docs file so a user can then edit it and save it. Is this possible?
You need to send the optional query parameter of convert
convert (boolean) Whether to convert this file to the corresponding
Google Docs format. (Default: false)
Documentation for Google Drive Insert

Google Docs document format?

What I'd like to accomplish: Download a Google Docs doc (with Google Drive API), modify it (for example highlight some text), then store it back to Google Drive (not messing up the format, so that it can be edited in the Google Docs app).
(Preemptive research: I know that you can do some integration with Google's hosted AppScript, but I want to do this offline. I also know that a Google Docs doc can be exported to other formats, but I see no sign of reimporting in the Google Drive API.)
I'm not hopeful this can be done:
* The meta-data file (that you can get via the Google Drive API) lacks a "downloadUrl" attribute
* In offline mode, the data (stored in .../File System/) is binary and the Unix "file " command doesn't know what format it is.
Is this off-limits with the current Google Drive API?
Your best (only) approach is to export the doc to a format that you can edit locally (html, docs, etc) and then reimport it. HTML is of course the easiest, but also the most lossy.

Google Realtime API with Google Docs

I would like to build an application on a webpage, that does as google docs:
I want to build an app that allow people to work on a document in collaboration
I start with this: https://developers.google.com/drive/realtime/realtime-quickstart
But the problem is that it creates a file with the mimetype is "application/vnd.google-apps.drive-sdk".
I would like to work with google docs format, so people can open them with their google drive and edit their later.
The file created is not the proper format, and find it me impossible to open it.
( I try to edit the mimetype with "application/vnd.google-apps.document", however it creates the file in the google drive but it can't find the file when it try to load it).
How to create a google doc in realtime ? (If you can post the code here, it would help me a lot)
Then, it want to add the toolbar for editing(bold, italic,...).
After that, it would like to add the google picker to select the file to load.

How To Set MIME Type Of Google Drive File

Using the HTML (div to load plusone.js) approach, is it possible to set the MIME Type of the generated Google Drive file?
Background
I'm trying to download CSV documents into Google Drive. I want customers to be able to open these files in Google Sheets with just a single click. Google Drive does not associate .csv files with Google Sheets automatically which means customers have to click here and there before they get the documents to open (not so good for my business).
I tried serving the documents with Google Sheets custom MIME Type application/vnd.google-apps.spreadsheet but it seems Drive completely ignores it.
If manipulating MIME Types won't work, I'll like to know any other means of associating generated files with Google Sheets such that customers can open generated documents automatically with a single click.
NB: I know its possible to set MIME Types in the Javascript and server-side flows using the Drive API and I have experience with the Drive API so please lets skip that :) I just want to get this done in the HTML flow.
Thanks.
Turn on conversion during uploads with convert parameter.
POST https://www.googleapis.com/upload/drive/v2/files?uploadType=media&convert=true