Members
(inner, constant) mimeType
Enum for the currently supported google mime-types
- Source:
Methods
(inner) autoInit()
In production just call this to set up access to the drive APIs
- Source:
(async, inner) getFile(withName) → {Promise.<{id:String, name:String}>}
Get a single file for the passed name. If a single file isn't found an error is thrown.
// @ts-ignore
Parameters:
Name | Type | Description |
---|---|---|
withName |
Object |
- Source:
Returns:
a single object that has the FILE_META_FOR_NAME_SEARCH properties
- Type
- Promise.<{id:String, name:String}>
Example
getFile({withName:"someName"}) //forces exactMatch:true
(async, inner) getFileId(withNameObj) → {Promise.<string>}
Convenience function that returns the id for a file
Parameters:
Name | Type | Description |
---|---|---|
withNameObj |
Object |
- Source:
Returns:
google id for the file
- Type
- Promise.<string>
Example
getFileId({withName:"SomeName"})
(async, inner) getFileNamesInFolder(folderOptions) → {Promise.<Array.<string>>}
Get just the names of the files in the folder (ofType is optional)
Parameters:
Name | Type | Description |
---|---|---|
folderOptions |
Object |
- Source:
Returns:
array of strings containing filenames
- Type
- Promise.<Array.<string>>
Example
getFileNamesInFolder({withFolderId:"someId", ofType:mimeType.SPREADSHEET)
(async, inner) getFiles(fileOptions) → {Promise.<Array.<{id:String, name:String}>>}
Get a list of files/folders that match
Parameters:
Name | Type | Description |
---|---|---|
fileOptions |
Object |
- Source:
Returns:
- Type
- Promise.<Array.<{id:String, name:String}>>
Example
getFiles({withName:"someName", exactMatch:true})
(async, inner) getFilesInFolder(folderOptions) → {Promise.<Array.<{name, id, mimeType}>>}
Get all the Files in the passed folderId (ofType is optional)
Parameters:
Name | Type | Description |
---|---|---|
folderOptions |
Object |
- Source:
Returns:
array of file objects where each object has the properties
specified by the constant FILE_META_FOR_FOLDER_SEARCH
- Type
- Promise.<Array.<{name, id, mimeType}>>
Example
getFilesInFolder({withFolderId:"someId", ofType:mimeType:SPREADSHEET})
(async, inner) getFilesRecursively(folderOptions) → {Promise.<Array.<{FILE_META_FOR_FOLDER_SEARCH}>>}
Get the files in the parent folder and all the children folders (ofType is optional)
Parameters:
Name | Type | Description |
---|---|---|
folderOptions |
Object |
- Source:
Returns:
array of file objects where each object has the properties
specified by the constant FILE_META_FOR_FOLDER_SEARCH
- Type
- Promise.<Array.<{FILE_META_FOR_FOLDER_SEARCH}>>
Example
getFilesRecursively({withFolderId:"someId", ofType:mimeType.SPREADSHEET})
(inner) getMimeTypeClause(type) → {string}
Private helper function to look up the mimetype string for the passed enum and construct and "and" clause that can be used in the API search query. The FILE enum isn't a type the API understands but we use it to mean any type of file but NOT a folder.
Parameters:
Name | Type | Description |
---|---|---|
type |
number |
- Source:
Returns:
the additional clause to limit the search for the specified type.
For example if mimeType.SPREADSHEET was passed in, then the clause
will be returned.
- Type
- string
Example
getMimeTypeClause(mimeType.SPREADSHEET) will return `and mimeType = application/vnd.google-apps.spreadsheet`
(inner) init()
Allow access to google drive APIs via the driveService (this version for testing)
- Source:
(async, inner) listFiles() → {Promise.<Array.<{FILE_META_FOR_FOLDER_SEARCH}>>}
Just get the files for the user. Will only return the google API max of 1000 files.
- Source:
Returns:
array of objects, where each object
has the properties specified by the constant FILE_META_FOR_FOLDER_SEARCH
- Type
- Promise.<Array.<{FILE_META_FOR_FOLDER_SEARCH}>>
Example
listFiles()