Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@robinbobin/react-native-google-drive-api-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@robinbobin/react-native-google-drive-api-wrapper - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

UnexpectedFileCountError.js

28

api/Files.js

@@ -5,2 +5,3 @@ import GDriveApi from "./GDriveApi";

import MimeTypes from "../MimeTypes";
import UnexpectedFileCountError from "../UnexpectedFileCountError";

@@ -21,2 +22,29 @@ export default class Files extends GDriveApi {

async createIfNotExists(queryParameters, uploader) {
uploader.setIdOfFileToUpdate();
const result = {};
const files = (await this.list(queryParameters)).files;
switch (files.length) {
case 0:
result.alreadyExisted = false;
result.result = await uploader.execute();
break;
case 1:
result.alreadyExisted = true;
result.result = files[0];
break;
default:
throw new UnexpectedFileCountError([0, 1], files.length);
}
return result;
}
delete(fileId) {

@@ -23,0 +51,0 @@ return this.createFetcher()

4

index.js

@@ -5,2 +5,3 @@ import GDrive from "./GDrive";

import MimeTypes from "./MimeTypes";
import UnexpectedFileCountError from "./UnexpectedFileCountError";

@@ -11,3 +12,4 @@ export {

ListQueryBuilder,
MimeTypes
MimeTypes,
UnexpectedFileCountError
};

@@ -27,3 +27,3 @@ {

},
"version": "0.5.0"
"version": "0.6.0"
}

@@ -54,3 +54,4 @@ This wrapper facilitates the use of the [google drive api](https://developers.google.com/drive/v3/reference/).

8. <a name="c_permissions"></a>[Permissions](#permissions)
9. <a name="c_uploader"></a>[Uploader](#uploader)
9. <a name="c_unexpected_file_count_error"></a>[UnexpectedFileCountError](#unexpected_file_count_error)
10. <a name="c_uploader"></a>[Uploader](#uploader)

@@ -77,2 +78,3 @@ #### <a name="about"></a>[About](#c_about)

copy(fileId, queryParameters, requestBody = {})|Method|Creates a [copy](#https://developers.google.com/drive/api/v3/reference/files/copy) of a file. Returns a [Files resource](https://developers.google.com/drive/api/v3/reference/files#resource) if the call succeeds and [fetchCoercesTypes](#gdriveapi_fetch_coerces_types) is `true`.
createIfNotExists(queryParameters, uploader)|Method|Invokes `uploader.execute()` and returns its result, if the file described with `queryParameters` doesn't exist. Returns the result of `list(queryParameters)` otherwise. Throws [`UnexpectedFileCountError`](#unexpected_file_count_error) if there are 2 or more files matching `queryParameters`.
delete(fileId)|Method|[Deletes](https://developers.google.com/drive/api/v3/reference/files/delete) a file. Returns an empty string if the call succeeds and [fetchCoercesTypes](#gdriveapi_fetch_coerces_types) is `true`.

@@ -176,5 +178,15 @@ emptyTrash()|Method|Permanently [deletes](https://developers.google.com/drive/api/v3/reference/files/emptyTrash) all of the user's trashed files. Returns an empty string if the call succeeds and [fetchCoercesTypes](#gdriveapi_fetch_coerces_types) is `true`.

#### <a name="unexpected_file_count_error"></a>[UnexpectedFileCountError](#c_unexpected_file_count_error)
An instance of this class is thrown when the real number of files differs from the expected. All the properties are read-only.
Name|Type|Description
-|-|-
expectedCount|Array\|Number|The expected count.
realCount|Number|Real count.
#### <a name="uploader"></a>[Uploader](#c_uploader)
This class handles the [create](https://developers.google.com/drive/api/v3/reference/files/create) and [update](https://developers.google.com/drive/api/v3/reference/files/update) requests. Currently only `media`, `multipart` and metadata-only requests are supported.
This class handles the [create](https://developers.google.com/drive/api/v3/reference/files/create) and [update](https://developers.google.com/drive/api/v3/reference/files/update) requests. Currently only `media`, `multipart` and metadata-only requests are supported. All the methods except `execute()` can be chained.

@@ -194,2 +206,3 @@ Name|Description

-|-
v0.6.0|1. [`UnexpectedFileCountError`](#unexpected_file_count_error).<br>2. `Files.createIfNotExists()` is added.
v0.5.0|[`ListQueryBuilder`](#list_query_builder) added.

@@ -196,0 +209,0 @@ v0.4.0|[`Permissions`](#permissions) added.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc