Skip to main content

googledrive@1.0.0

create(content, fileName, options)
get(fileId)
update(fileId, content, options)

Functions

create

create(content, fileName, options) ⇒ function

Uploads a file to Google Drive.

Returns: function - An operation that uploads the file.

ParamTypeDescription
contentstringBase64 encoded file content.
fileNamestringName for the uploaded file.
optionsObjectFile upload parameters.
options.folderIdstringID of the parent folder.

Example: Upload a file to a root folder

create("SGVsbG8gV29ybGQ=", "hello-world.txt");

Example: Upload a file to a specificfolder

create("SGVsbG8gV29ybGQ=", "hello-world.txt", {
folderId: "15tLwRj0lmr4mGIslEm5QEAS8YJ1EAXep",
});

get

get(fileId) ⇒ function

Downloads a file from Google Drive.

Returns: function - An operation that retrieves the file as a base64 string.

ParamTypeDescription
fileIdstringID of the file to download.

Example: Download a file

get('1B1dHwY2uLgm_-U96LNl9zFsRYq8953jL')

update

update(fileId, content, options) ⇒ function

Updates an existing file in Google Drive.

Returns: function - An operation that updates the file.

ParamTypeDescription
fileIdstringID of the file to update.
contentstringBase64 encoded new content.
optionsObjectFile update options.

Example: Update a file

update('1B1dHwY2uLgm_-U96LNl9zFsRYq8953jL', 'SGVsbG8gTWlrZQ==');