It doesn't provide any authorization mechanism, so another package has to be used. I use react-native-google-signin (thanks for the great work guys!).
This is the "entry point" of the wrapper. It contains only static
methods and fields.
-
createFileMultipart()
Creates a file using multipart upload. Returns the result of fetch()
.
If contents
is a base64 string, set isBase64
to true
.
const contents = "My text file contents";
// or
const contents = [10, 20, 30];
GDrive.files.createFileMultipart(
contents,
"corresponding mime type", {
parents: ["root"],
name: "My file"
},
isBase64);
-
delete()
Deletes the specified file returning the result of fetch()
.
GDrive.files.delete(fileId);
-
get()
Gets a file's metadata or a text-file's content by ID. By default the metadata is returned. Use download()
for binary files. For queryParams
see "Optional query parameters" here. If you want the content of a text-file and not its metadata add alt: "media"
to queryParams
.
const queryParams = { ... };
GDrive.files.get(fileId, queryParams);
-
download()
Downloads the specified text or binary file.
For downloadFileOptions
see the description of downloadFile()
here. Please, bear in mind that fromUrl
is set automatically and any user supplied value will be overwritten.
The fileName
parameter must be the name of the file with the base64 extension or text
The meaning of queryParams
is the same as in get()
.
The function returns the result of RNFS.downloadFile(downloadFileOptions)
.
GDrive.files.download(fileId, downloadFileOptions, fileName, queryParams);
-
export()
Exports a google document, returning the result of fetch()
.
GDrive.files.export(fileId, mimeType);
-
getId()
Gets the id of the first file with the specified metadata. The function returns a Promise
. It's rejected on failure and resolved to the file id or undefined
(if nothing is found) on success.
GDrive.files.getId(
name: String, // The name.
parents: [String], // The parents.
mimeType: String, // The mime type.
trashed: Boolean // Whether the file is trashed. Default: false
);
-
list()
Lists or searches files returning the result of fetch()
.
GDrive.files.list({q: "'root' in parents"});
-
update()
Updates a file's metadata. returning the result of fetch()
.
GDrive.files.update("file_id", {
removeParents: "o_parent_id",
addParents: "parent_id",
resource: {
modifiedTime: new Date(Date.now()).toISOString(),
},
})
-
safeCreateFolder()
Gets the id of the first folder with the specified name
and parents
, creating the folder if it doesn't exist. The function returns a Promise
that is rejected on failure and resolved to the folder id on success.
GDrive.files.safeCreateFolder({
name: "My folder",
parents: ["root"]
});