@fett/synology-api 0.0.3-beta.2 → 0.0.3-beta.3
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/lib/modules/Api/Auth.d.ts +2 -4
- package/lib/modules/Api/Info.d.ts +1 -3
- package/lib/modules/FileStation/Upload.base.js +0 -3
- package/lib/modules/FileStation/Upload.d.ts +1 -1
- package/lib/modules/FileStation/Upload.js +25 -21
- package/lib/modules/FileStation/Upload.rn.d.ts +1 -1
- package/lib/modules/FileStation/Upload.rn.js +10 -6
- package/lib/modules/FileStation/index.d.ts +2 -1
- package/lib/modules/FileStation/index.rn.d.ts +2 -1
- package/package.json +3 -6
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { SynologyApiResponse } from "../../types/index.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare function login(core: SynologyApi | RnSynologyApi): Promise<SynologyApiResponse>;
|
|
5
|
-
export declare function logout(core: SynologyApi | RnSynologyApi): Promise<void>;
|
|
2
|
+
export declare function login(core: any): Promise<SynologyApiResponse>;
|
|
3
|
+
export declare function logout(core: any): Promise<void>;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { SynologyApiResponse } from "../../types/index.js";
|
|
2
|
-
|
|
3
|
-
import { RnSynologyApi } from "../../core.rn.js";
|
|
4
|
-
export declare function getApiInfo(core: SynologyApi | RnSynologyApi): Promise<SynologyApiResponse>;
|
|
2
|
+
export declare function getApiInfo(core: any): Promise<SynologyApiResponse>;
|
|
@@ -6,9 +6,6 @@ var OverwriteEnum;
|
|
|
6
6
|
OverwriteEnum["SKIP"] = "skip";
|
|
7
7
|
})(OverwriteEnum || (OverwriteEnum = {}));
|
|
8
8
|
export async function uploadFileBase(params, parseFileFn) {
|
|
9
|
-
if (!this.isConnecting) {
|
|
10
|
-
await this.connect();
|
|
11
|
-
}
|
|
12
9
|
const { path, file, overwrite = OverwriteEnum.OVERWRITE, create_parents = true } = params;
|
|
13
10
|
const api = this.getApiInfoByName(FileStationApi.Upload);
|
|
14
11
|
let formData = createFormData();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function uploadFile(...args: any[]): Promise<import("./Upload.base.js").UploadFileResponse>;
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { isNode } from "../../utils/index.js";
|
|
2
2
|
import { uploadFileBase } from "./Upload.base.js";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// nodejs environment
|
|
7
|
-
if (isNode) {
|
|
8
|
-
let fileContent;
|
|
9
|
-
let fileName = "";
|
|
10
|
-
if (typeof file === "string") {
|
|
11
|
-
fileName = await import("path").then((p) => p.basename(file));
|
|
12
|
-
fileContent = await import("node:fs/promises").then((fs) => fs.readFile(file));
|
|
13
|
-
}
|
|
14
|
-
formdata.append("file", fileContent, {
|
|
15
|
-
filename: fileName,
|
|
16
|
-
contentType: "application/octet-stream", // 可根据文件类型修改
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
// for browser environment
|
|
21
|
-
formdata.append("file", file);
|
|
3
|
+
export async function uploadFile(...args) {
|
|
4
|
+
if (!this.isConnecting) {
|
|
5
|
+
await this.connect();
|
|
22
6
|
}
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
return uploadFileBase(...args, async (file, formdata) => {
|
|
9
|
+
// nodejs environment
|
|
10
|
+
if (isNode) {
|
|
11
|
+
let fileContent;
|
|
12
|
+
let fileName = "";
|
|
13
|
+
if (typeof file === "string") {
|
|
14
|
+
fileName = await import("path").then((p) => p.basename(file));
|
|
15
|
+
fileContent = await import("node:fs/promises").then((fs) => fs.readFile(file));
|
|
16
|
+
}
|
|
17
|
+
formdata.append("file", fileContent, {
|
|
18
|
+
filename: fileName,
|
|
19
|
+
contentType: "application/octet-stream", // 可根据文件类型修改
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// for browser environment
|
|
24
|
+
formdata.append("file", file);
|
|
25
|
+
}
|
|
26
|
+
return formdata;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function uploadFile(...args: any[]): Promise<void>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { uploadFileBase } from "./Upload.base.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
export async function uploadFile(...args) {
|
|
3
|
+
if (!this.isConnecting) {
|
|
4
|
+
await this.connect();
|
|
5
|
+
}
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
uploadFileBase(...args, async (file, formdata) => {
|
|
8
|
+
formdata.append("file", file);
|
|
9
|
+
return formdata;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { uploadFile } from "./Upload.js";
|
|
1
2
|
export * from "./index.js";
|
|
2
3
|
export type * from "./index.js";
|
|
3
4
|
export declare const METHODS: {
|
|
4
|
-
uploadFile:
|
|
5
|
+
uploadFile: typeof uploadFile;
|
|
5
6
|
getInfo: typeof import("./Info.js").getInfo;
|
|
6
7
|
getFileList: typeof import("./List.js").getFileList;
|
|
7
8
|
getShareFileList: typeof import("./List.js").getShareFileList;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { uploadFile } from "./Upload.rn.js";
|
|
1
2
|
export * from "./index.js";
|
|
2
3
|
export declare const METHODS: {
|
|
3
|
-
uploadFile:
|
|
4
|
+
uploadFile: typeof uploadFile;
|
|
4
5
|
getInfo: typeof import("./Info.js").getInfo;
|
|
5
6
|
getFileList: typeof import("./List.js").getFileList;
|
|
6
7
|
getShareFileList: typeof import("./List.js").getShareFileList;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fett/synology-api",
|
|
3
|
-
"version": "0.0.3-beta.
|
|
3
|
+
"version": "0.0.3-beta.3",
|
|
4
4
|
"description": "synology api for nodejs",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -11,11 +11,8 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
13
|
"import": "./lib/index.js",
|
|
14
|
-
"require": "./lib/index.js"
|
|
15
|
-
|
|
16
|
-
"./react-native": {
|
|
17
|
-
"import": "./lib/index.rn.js",
|
|
18
|
-
"require": "./lib/index.rn.js"
|
|
14
|
+
"require": "./lib/index.js",
|
|
15
|
+
"react-native": "./lib/index.rn.js"
|
|
19
16
|
}
|
|
20
17
|
},
|
|
21
18
|
"files": [
|