react-native-cloud-storage 2.2.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/android/build.gradle +101 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/voicekit/CloudStorageError.kt +86 -0
- package/android/src/main/java/com/voicekit/CloudStorageLocalFileSystemModule.kt +236 -0
- package/android/src/main/java/com/voicekit/CloudStoragePackage.kt +17 -0
- package/android/src/main/java/com/voicekit/FileUtils.kt +41 -0
- package/android/src/main/java/com/voicekit/Types.kt +6 -0
- package/app.plugin.js +1 -1
- package/{lib/commonjs/RNCloudStorage.js → dist/commonjs/cloud-storage.js} +130 -80
- package/dist/commonjs/cloud-storage.js.map +1 -0
- package/dist/commonjs/expo-plugin/index.js +13 -0
- package/dist/commonjs/expo-plugin/index.js.map +1 -0
- package/{lib/commonjs/expo-plugin/withRNCloudStorageIos.js → dist/commonjs/expo-plugin/ios.js} +1 -1
- package/dist/commonjs/expo-plugin/ios.js.map +1 -0
- package/{lib/commonjs/hooks/useCloudFile.js → dist/commonjs/hooks/use-cloud-file.js} +26 -8
- package/dist/commonjs/hooks/use-cloud-file.js.map +1 -0
- package/{lib/commonjs/hooks/useIsCloudAvailable.js → dist/commonjs/hooks/use-is-cloud-available.js} +3 -3
- package/dist/commonjs/hooks/use-is-cloud-available.js.map +1 -0
- package/{lib → dist}/commonjs/index.js +10 -10
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/storages/cloudkit.js +10 -0
- package/dist/commonjs/storages/cloudkit.js.map +1 -0
- package/{lib/commonjs → dist/commonjs/storages}/google-drive/client.js +80 -38
- package/dist/commonjs/storages/google-drive/client.js.map +1 -0
- package/{lib/commonjs → dist/commonjs/storages}/google-drive/index.js +120 -64
- package/dist/commonjs/storages/google-drive/index.js.map +1 -0
- package/dist/commonjs/storages/google-drive/types.js.map +1 -0
- package/dist/commonjs/types/native.js +28 -0
- package/dist/commonjs/types/native.js.map +1 -0
- package/{lib/commonjs/utils/CloudStorageError.js → dist/commonjs/utils/cloud-storage-error.js} +3 -1
- package/dist/commonjs/utils/cloud-storage-error.js.map +1 -0
- package/dist/commonjs/utils/constants.js +24 -0
- package/dist/commonjs/utils/constants.js.map +1 -0
- package/dist/commonjs/utils/local-fs.js +16 -0
- package/dist/commonjs/utils/local-fs.js.map +1 -0
- package/dist/commonjs/utils/native.js +35 -0
- package/dist/commonjs/utils/native.js.map +1 -0
- package/{lib/module/RNCloudStorage.js → dist/module/cloud-storage.js} +130 -80
- package/dist/module/cloud-storage.js.map +1 -0
- package/dist/module/expo-plugin/index.js +8 -0
- package/dist/module/expo-plugin/index.js.map +1 -0
- package/{lib/module/expo-plugin/withRNCloudStorageIos.js → dist/module/expo-plugin/ios.js} +1 -1
- package/dist/module/expo-plugin/ios.js.map +1 -0
- package/{lib/module/hooks/useCloudFile.js → dist/module/hooks/use-cloud-file.js} +25 -7
- package/dist/module/hooks/use-cloud-file.js.map +1 -0
- package/{lib/module/hooks/useIsCloudAvailable.js → dist/module/hooks/use-is-cloud-available.js} +2 -2
- package/dist/module/hooks/use-is-cloud-available.js.map +1 -0
- package/dist/module/index.js +9 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/storages/cloudkit.js +6 -0
- package/dist/module/storages/cloudkit.js.map +1 -0
- package/{lib/module → dist/module/storages}/google-drive/client.js +80 -38
- package/dist/module/storages/google-drive/client.js.map +1 -0
- package/{lib/module → dist/module/storages}/google-drive/index.js +119 -62
- package/dist/module/storages/google-drive/index.js.map +1 -0
- package/dist/module/storages/google-drive/types.js.map +1 -0
- package/dist/module/types/native.js +24 -0
- package/dist/module/types/native.js.map +1 -0
- package/{lib/module/utils/CloudStorageError.js → dist/module/utils/cloud-storage-error.js} +3 -1
- package/dist/module/utils/cloud-storage-error.js.map +1 -0
- package/dist/module/utils/constants.js +20 -0
- package/dist/module/utils/constants.js.map +1 -0
- package/dist/module/utils/local-fs.js +12 -0
- package/dist/module/utils/local-fs.js.map +1 -0
- package/dist/module/utils/native.js +30 -0
- package/dist/module/utils/native.js.map +1 -0
- package/{lib/typescript/RNCloudStorage.d.ts → dist/typescript/cloud-storage.d.ts} +60 -8
- package/dist/typescript/cloud-storage.d.ts.map +1 -0
- package/{lib/typescript/expo-plugin/withRNCloudStorage.d.ts → dist/typescript/expo-plugin/index.d.ts} +1 -1
- package/dist/typescript/expo-plugin/index.d.ts.map +1 -0
- package/{lib/typescript/expo-plugin/withRNCloudStorageIos.d.ts → dist/typescript/expo-plugin/ios.d.ts} +1 -1
- package/dist/typescript/expo-plugin/ios.d.ts.map +1 -0
- package/{lib/typescript/hooks/useCloudFile.d.ts → dist/typescript/hooks/use-cloud-file.d.ts} +22 -4
- package/dist/typescript/hooks/use-cloud-file.d.ts.map +1 -0
- package/{lib/typescript/hooks/useIsCloudAvailable.d.ts → dist/typescript/hooks/use-is-cloud-available.d.ts} +2 -2
- package/dist/typescript/hooks/use-is-cloud-available.d.ts.map +1 -0
- package/dist/typescript/index.d.ts +7 -0
- package/dist/typescript/index.d.ts.map +1 -0
- package/dist/typescript/storages/cloudkit.d.ts +3 -0
- package/dist/typescript/storages/cloudkit.d.ts.map +1 -0
- package/{lib/typescript → dist/typescript/storages}/google-drive/client.d.ts +9 -2
- package/dist/typescript/storages/google-drive/client.d.ts.map +1 -0
- package/dist/typescript/storages/google-drive/index.d.ts +35 -0
- package/dist/typescript/storages/google-drive/index.d.ts.map +1 -0
- package/dist/typescript/storages/google-drive/types.d.ts.map +1 -0
- package/dist/typescript/types/native.d.ts +64 -0
- package/dist/typescript/types/native.d.ts.map +1 -0
- package/dist/typescript/utils/cloud-storage-error.d.ts +8 -0
- package/dist/typescript/utils/cloud-storage-error.d.ts.map +1 -0
- package/dist/typescript/utils/constants.d.ts +4 -0
- package/dist/typescript/utils/constants.d.ts.map +1 -0
- package/{lib → dist}/typescript/utils/helpers.d.ts.map +1 -1
- package/dist/typescript/utils/local-fs.d.ts +3 -0
- package/dist/typescript/utils/local-fs.d.ts.map +1 -0
- package/dist/typescript/utils/native.d.ts +7 -0
- package/dist/typescript/utils/native.d.ts.map +1 -0
- package/ios/CloudStorage.xcodeproj/project.pbxproj +12 -6
- package/ios/{CloudStorage.m → CloudStorageCloudKit.m} +4 -2
- package/ios/{CloudStorage.swift → CloudStorageCloudKit.swift} +60 -5
- package/ios/CloudStorageLocalFileSystem.m +15 -0
- package/ios/CloudStorageLocalFileSystem.swift +215 -0
- package/ios/Utils/CloudKitUtils.swift +4 -4
- package/ios/Utils/CloudStorageError.swift +8 -0
- package/ios/Utils/FileUtils.swift +19 -0
- package/ios/Utils/Types.swift +7 -1
- package/package.json +44 -103
- package/src/{RNCloudStorage.ts → cloud-storage.ts} +147 -85
- package/src/expo-plugin/{withRNCloudStorage.ts → index.ts} +2 -2
- package/src/hooks/{useCloudFile.ts → use-cloud-file.ts} +24 -6
- package/src/hooks/{useIsCloudAvailable.ts → use-is-cloud-available.ts} +1 -1
- package/src/index.ts +5 -6
- package/src/storages/cloudkit.ts +5 -0
- package/src/{google-drive → storages/google-drive}/client.ts +98 -40
- package/src/{google-drive → storages/google-drive}/index.ts +172 -89
- package/src/types/native.ts +50 -14
- package/src/utils/cloud-storage-error.ts +15 -0
- package/src/utils/constants.ts +20 -0
- package/src/utils/local-fs.ts +19 -0
- package/src/utils/native.ts +40 -0
- package/lib/commonjs/RNCloudStorage.js.map +0 -1
- package/lib/commonjs/expo-plugin/withRNCloudStorage.js +0 -13
- package/lib/commonjs/expo-plugin/withRNCloudStorage.js.map +0 -1
- package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js.map +0 -1
- package/lib/commonjs/google-drive/client.js.map +0 -1
- package/lib/commonjs/google-drive/index.js.map +0 -1
- package/lib/commonjs/google-drive/types.js.map +0 -1
- package/lib/commonjs/hooks/useCloudFile.js.map +0 -1
- package/lib/commonjs/hooks/useIsCloudAvailable.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/types/native.js +0 -26
- package/lib/commonjs/types/native.js.map +0 -1
- package/lib/commonjs/utils/CloudStorageError.js.map +0 -1
- package/lib/module/RNCloudStorage.js.map +0 -1
- package/lib/module/expo-plugin/withRNCloudStorage.js +0 -8
- package/lib/module/expo-plugin/withRNCloudStorage.js.map +0 -1
- package/lib/module/expo-plugin/withRNCloudStorageIos.js.map +0 -1
- package/lib/module/google-drive/client.js.map +0 -1
- package/lib/module/google-drive/index.js.map +0 -1
- package/lib/module/google-drive/types.js.map +0 -1
- package/lib/module/hooks/useCloudFile.js.map +0 -1
- package/lib/module/hooks/useIsCloudAvailable.js.map +0 -1
- package/lib/module/index.js +0 -10
- package/lib/module/index.js.map +0 -1
- package/lib/module/types/native.js +0 -22
- package/lib/module/types/native.js.map +0 -1
- package/lib/module/utils/CloudStorageError.js.map +0 -1
- package/lib/typescript/RNCloudStorage.d.ts.map +0 -1
- package/lib/typescript/expo-plugin/withRNCloudStorage.d.ts.map +0 -1
- package/lib/typescript/expo-plugin/withRNCloudStorageIos.d.ts.map +0 -1
- package/lib/typescript/google-drive/client.d.ts.map +0 -1
- package/lib/typescript/google-drive/index.d.ts +0 -34
- package/lib/typescript/google-drive/index.d.ts.map +0 -1
- package/lib/typescript/google-drive/types.d.ts.map +0 -1
- package/lib/typescript/hooks/useCloudFile.d.ts.map +0 -1
- package/lib/typescript/hooks/useIsCloudAvailable.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -8
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/types/native.d.ts +0 -40
- package/lib/typescript/types/native.d.ts.map +0 -1
- package/lib/typescript/utils/CloudStorageError.d.ts +0 -8
- package/lib/typescript/utils/CloudStorageError.d.ts.map +0 -1
- package/src/utils/CloudStorageError.ts +0 -14
- /package/{lib → dist}/commonjs/expo-plugin/types/index.js +0 -0
- /package/{lib → dist}/commonjs/expo-plugin/types/index.js.map +0 -0
- /package/{lib/commonjs → dist/commonjs/storages}/google-drive/types.js +0 -0
- /package/{lib → dist}/commonjs/types/main.js +0 -0
- /package/{lib → dist}/commonjs/types/main.js.map +0 -0
- /package/{lib → dist}/commonjs/utils/helpers.js +0 -0
- /package/{lib → dist}/commonjs/utils/helpers.js.map +0 -0
- /package/{lib → dist}/module/expo-plugin/types/index.js +0 -0
- /package/{lib → dist}/module/expo-plugin/types/index.js.map +0 -0
- /package/{lib → dist}/module/package.json +0 -0
- /package/{lib/module → dist/module/storages}/google-drive/types.js +0 -0
- /package/{lib → dist}/module/types/main.js +0 -0
- /package/{lib → dist}/module/types/main.js.map +0 -0
- /package/{lib → dist}/module/utils/helpers.js +0 -0
- /package/{lib → dist}/module/utils/helpers.js.map +0 -0
- /package/{lib → dist}/typescript/expo-plugin/types/index.d.ts +0 -0
- /package/{lib → dist}/typescript/expo-plugin/types/index.d.ts.map +0 -0
- /package/{lib/typescript → dist/typescript/storages}/google-drive/types.d.ts +0 -0
- /package/{lib → dist}/typescript/types/main.d.ts +0 -0
- /package/{lib → dist}/typescript/types/main.d.ts.map +0 -0
- /package/{lib → dist}/typescript/utils/helpers.d.ts +0 -0
- /package/src/expo-plugin/{withRNCloudStorageIos.ts → ios.ts} +0 -0
- /package/src/{google-drive → storages/google-drive}/types.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CloudStorageProviderOptions, type DeepRequired } from '
|
|
1
|
+
import { type CloudStorageProviderOptions, type DeepRequired } from '../../types/main';
|
|
2
2
|
import {
|
|
3
3
|
MimeTypes,
|
|
4
4
|
type GoogleDriveFile,
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
type GoogleDriveListOperationQueryParameters,
|
|
7
7
|
type GoogleDriveListOperationResponse,
|
|
8
8
|
} from './types';
|
|
9
|
+
import { localFileSystem } from '../../utils/local-fs';
|
|
9
10
|
|
|
10
11
|
const BASE_URL = 'https://www.googleapis.com/drive/v3';
|
|
11
12
|
const BASE_UPLOAD_URL = 'https://www.googleapis.com/upload/drive/v3';
|
|
@@ -13,19 +14,19 @@ const MULTIPART_BOUNDARY = 'foo_bar_baz';
|
|
|
13
14
|
|
|
14
15
|
export class GoogleDriveHttpError extends Error {
|
|
15
16
|
public status: number;
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
18
|
public json: any;
|
|
17
19
|
|
|
18
|
-
constructor(message: string, status: number, json:
|
|
20
|
+
constructor(message: string, status: number, json: unknown) {
|
|
19
21
|
super(message);
|
|
20
22
|
this.status = status;
|
|
21
23
|
this.json = json;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
// TODO: fetch timeout
|
|
26
27
|
// TODO: properly handle errors
|
|
27
28
|
export default class GoogleDriveApiClient {
|
|
28
|
-
private _fetchTimeout:
|
|
29
|
+
private _fetchTimeout: NodeJS.Timeout | null = null;
|
|
29
30
|
private options: DeepRequired<CloudStorageProviderOptions['googledrive']>;
|
|
30
31
|
|
|
31
32
|
constructor(options: DeepRequired<CloudStorageProviderOptions['googledrive']>) {
|
|
@@ -33,7 +34,7 @@ export default class GoogleDriveApiClient {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
private buildQueryString(query: object): string {
|
|
36
|
-
let
|
|
37
|
+
let result = Object.entries(query)
|
|
37
38
|
.filter(([, value]) => value !== undefined)
|
|
38
39
|
.map(([key, value]) => {
|
|
39
40
|
if (typeof value === 'boolean') return `${encodeURIComponent(key)}=${value ? 'true' : 'false'}`;
|
|
@@ -41,13 +42,13 @@ export default class GoogleDriveApiClient {
|
|
|
41
42
|
})
|
|
42
43
|
.join('&');
|
|
43
44
|
|
|
44
|
-
if (
|
|
45
|
-
|
|
45
|
+
if (result) {
|
|
46
|
+
result = `?${result}`;
|
|
46
47
|
}
|
|
47
|
-
return
|
|
48
|
+
return result;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
private async request<T extends
|
|
51
|
+
private async request<T extends object | string | void = void>(
|
|
51
52
|
operation: `/${string}`,
|
|
52
53
|
{ queryParameters, baseUrl, ...options }: RequestInit & { queryParameters?: object; baseUrl?: string } = {}
|
|
53
54
|
): Promise<T> {
|
|
@@ -57,7 +58,7 @@ export default class GoogleDriveApiClient {
|
|
|
57
58
|
if (queryParameters) {
|
|
58
59
|
path += this.buildQueryString(queryParameters);
|
|
59
60
|
}
|
|
60
|
-
clearTimeout(this._fetchTimeout);
|
|
61
|
+
if (this._fetchTimeout !== null) clearTimeout(this._fetchTimeout);
|
|
61
62
|
const abortController: AbortController = new AbortController();
|
|
62
63
|
this._fetchTimeout = setTimeout(() => {
|
|
63
64
|
abortController.abort();
|
|
@@ -72,11 +73,20 @@ export default class GoogleDriveApiClient {
|
|
|
72
73
|
});
|
|
73
74
|
if (!response.ok) {
|
|
74
75
|
let errorMessage: string;
|
|
75
|
-
let json:
|
|
76
|
+
let json: unknown = null;
|
|
76
77
|
try {
|
|
77
78
|
json = await response.json();
|
|
78
|
-
errorMessage =
|
|
79
|
-
|
|
79
|
+
errorMessage =
|
|
80
|
+
typeof json === 'object' &&
|
|
81
|
+
json !== null &&
|
|
82
|
+
'error' in json &&
|
|
83
|
+
typeof json.error === 'object' &&
|
|
84
|
+
json.error !== null &&
|
|
85
|
+
'message' in json.error &&
|
|
86
|
+
typeof json.error.message === 'string'
|
|
87
|
+
? json.error.message
|
|
88
|
+
: `Request failed with status ${response.status}`;
|
|
89
|
+
} catch {
|
|
80
90
|
errorMessage = `Request failed with status ${response.status}`;
|
|
81
91
|
}
|
|
82
92
|
throw new GoogleDriveHttpError(errorMessage, response.status, json);
|
|
@@ -93,13 +103,15 @@ export default class GoogleDriveApiClient {
|
|
|
93
103
|
|
|
94
104
|
private buildMultiPartBody(metadata: object, media: { mimeType: string; body: string }): string {
|
|
95
105
|
const body: string[] = [];
|
|
96
|
-
body.push(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
body.push(
|
|
107
|
+
`--${MULTIPART_BOUNDARY}\r\n`,
|
|
108
|
+
`Content-Type: ${MimeTypes.JSON}; charset=UTF-8\r\n\r\n`,
|
|
109
|
+
`${JSON.stringify(metadata)}\r\n`,
|
|
110
|
+
`--${MULTIPART_BOUNDARY}\r\n`,
|
|
111
|
+
`Content-Type: ${media.mimeType}\r\n\r\n`,
|
|
112
|
+
`${media.body}\r\n`,
|
|
113
|
+
`--${MULTIPART_BOUNDARY}--`
|
|
114
|
+
);
|
|
103
115
|
|
|
104
116
|
return body.join('');
|
|
105
117
|
}
|
|
@@ -149,20 +161,42 @@ export default class GoogleDriveApiClient {
|
|
|
149
161
|
|
|
150
162
|
public async createFile(
|
|
151
163
|
metadata: { name: string; parents?: string[] },
|
|
152
|
-
media: { mimeType: string; body: string }
|
|
164
|
+
media: { mimeType: string; body: string } | { mimeType: string; localPath: string }
|
|
153
165
|
): Promise<void> {
|
|
154
|
-
|
|
166
|
+
if ('body' in media) {
|
|
167
|
+
const multipartRequestBody = this.buildMultiPartBody(metadata, media);
|
|
168
|
+
|
|
169
|
+
await this.request(`/files`, {
|
|
170
|
+
queryParameters: { uploadType: 'multipart' },
|
|
171
|
+
method: 'POST',
|
|
172
|
+
headers: {
|
|
173
|
+
'Content-Type': `multipart/related; boundary=${MULTIPART_BOUNDARY}`,
|
|
174
|
+
'Content-Length': multipartRequestBody.length.toString(),
|
|
175
|
+
},
|
|
176
|
+
body: multipartRequestBody,
|
|
177
|
+
baseUrl: BASE_UPLOAD_URL,
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
// First, create an empty file with the required metadata
|
|
181
|
+
const file = await this.request<{ id: string }>(`/files`, {
|
|
182
|
+
method: 'POST',
|
|
183
|
+
headers: {
|
|
184
|
+
'Content-Type': MimeTypes.JSON,
|
|
185
|
+
},
|
|
186
|
+
body: JSON.stringify({ ...metadata, mimeType: media.mimeType }),
|
|
187
|
+
});
|
|
155
188
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
'
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
189
|
+
// Then, upload the binary content via the native helper module
|
|
190
|
+
const remoteUri = `${BASE_UPLOAD_URL}/files/${file.id}?uploadType=media`;
|
|
191
|
+
await localFileSystem.uploadFile(media.localPath, remoteUri, {
|
|
192
|
+
method: 'PATCH',
|
|
193
|
+
uploadType: 'binary',
|
|
194
|
+
headers: {
|
|
195
|
+
'Authorization': `Bearer ${this.options.accessToken}`,
|
|
196
|
+
'Content-Type': media.mimeType,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
}
|
|
166
200
|
}
|
|
167
201
|
|
|
168
202
|
public async createDirectory(metadata: { name: string; parents?: string[] }): Promise<void> {
|
|
@@ -175,16 +209,40 @@ export default class GoogleDriveApiClient {
|
|
|
175
209
|
});
|
|
176
210
|
}
|
|
177
211
|
|
|
178
|
-
public async updateFile(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
212
|
+
public async updateFile(
|
|
213
|
+
fileId: string,
|
|
214
|
+
media: { mimeType: string; body: string } | { mimeType: string; localPath: string }
|
|
215
|
+
): Promise<void> {
|
|
216
|
+
if ('body' in media) {
|
|
217
|
+
await this.request(`/files/${fileId}`, {
|
|
218
|
+
queryParameters: { uploadType: 'media' },
|
|
219
|
+
method: 'PATCH',
|
|
220
|
+
headers: {
|
|
221
|
+
'Content-Type': media.mimeType,
|
|
222
|
+
'Content-Length': media.body.length.toString(),
|
|
223
|
+
},
|
|
224
|
+
body: media.body,
|
|
225
|
+
baseUrl: BASE_UPLOAD_URL,
|
|
226
|
+
});
|
|
227
|
+
} else {
|
|
228
|
+
const remoteUri = `${BASE_UPLOAD_URL}/files/${fileId}?uploadType=media`;
|
|
229
|
+
await localFileSystem.uploadFile(media.localPath, remoteUri, {
|
|
230
|
+
method: 'PATCH',
|
|
231
|
+
uploadType: 'binary',
|
|
232
|
+
headers: {
|
|
233
|
+
'Authorization': `Bearer ${this.options.accessToken}`,
|
|
234
|
+
'Content-Type': media.mimeType,
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public async downloadFile(fileId: string, localPath: string): Promise<void> {
|
|
241
|
+
const remoteUri = `${BASE_URL}/files/${fileId}?alt=media`;
|
|
242
|
+
await localFileSystem.downloadFile(remoteUri, localPath, {
|
|
182
243
|
headers: {
|
|
183
|
-
|
|
184
|
-
'Content-Length': media.body.length.toString(),
|
|
244
|
+
Authorization: `Bearer ${this.options.accessToken}`,
|
|
185
245
|
},
|
|
186
|
-
body: media.body,
|
|
187
|
-
baseUrl: BASE_UPLOAD_URL,
|
|
188
246
|
});
|
|
189
247
|
}
|
|
190
248
|
}
|