public class GoogleDriveFileSystem extends FileSystem
Modifier and Type | Field and Description |
---|---|
static String |
GOOGLE_FOLDER_TYPE |
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
GoogleDriveFileSystem(String appName,
String userName,
InputStream clientSecrets,
File credentialsFolder)
Enables access to Google Drive.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the Google Drive connection.
|
String |
getFileId(String fileName)
Returns the first occurence of the Google Drive File Id with the matching
fileName . |
String |
getFolderId(String folderName)
Returns the first occurence of the Google Drive Folder Id with the matching
folderName . |
List<File> |
listFolder(String folderName)
Returns a
List of all Google Drive files and folders under the specified folder. |
List<File> |
listRootFolder()
Returns a
List of all Google Drive files and folders. |
void |
open()
Opens a connection to the Google Drive file system.
|
InputStream |
readFile(String fileName)
Reads the first occurence of a Google Drive File with matching
fileName . |
InputStream |
readFile(String folderName,
String fileName)
Reads the first occurence of a Google Drive File with matching
fileName
in the specified folderName . |
OutputStream |
writeFile(String fileName)
Writes the file to the Google Drive File System.
|
OutputStream |
writeFile(String folderName,
String fileName)
Write the file to the specified folder.
|
addElapsedtime, addExceptionProperties, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getNestedEndpoint, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getRootEndpoint, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription, toString
public static final String GOOGLE_FOLDER_TYPE
public GoogleDriveFileSystem(String appName, String userName, InputStream clientSecrets, File credentialsFolder)
appName
- application name to use when connecting to Google DriveuserName
- the username of the Google Drive accountclientSecrets
- the JSON file client secret provided by Google DrivecredentialsFolder
- the folder to store the Google Drive Credentialspublic void open() throws DataException
open
in class Endpoint
DataException
public void close() throws DataException
close
in class Endpoint
DataException
public List<File> listFolder(String folderName) throws Throwable
List
of all Google Drive files and folders under the specified folder.folderName
- name of the folderList
or null
if none is foundThrowable
public List<File> listRootFolder() throws Throwable
List
of all Google Drive files and folders. Including files in the trash.List
Throwable
public InputStream readFile(String fileName) throws Throwable
fileName
. It's possible that
multiple files will have the same file name but different file ids.fileName
- the file name to read.InputStream
Throwable
public InputStream readFile(String folderName, String fileName) throws Throwable
fileName
in the specified folderName
. It's possible that
multiple files will have the same file name but different file ids.folderName
- the folder the file belongs tofileName
- the name of the fileInputStream
Throwable
public OutputStream writeFile(String fileName) throws Throwable
fileName
- the name of the fileOutputStream
for writingThrowable
public OutputStream writeFile(String folderName, String fileName) throws Throwable
folderName
- the name of the folderfileName
- the name of the fileOutputStream
for writingThrowable
public String getFolderId(String folderName) throws Throwable
folderName
.folderName
- the name of the folder to search fornull
if none is foundThrowable
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.