terabox-upload-tool 1.3.1 → 1.4.1

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.
@@ -1,52 +1,38 @@
1
1
  const axios = require('axios');
2
2
 
3
- /**
4
- * Generates a short URL for a file in Terabox.
5
- * @param {string} ndus - User authentication token.
6
- * @param {string} path - The file path in Terabox.
7
- * @param {string} fid - The file ID.
8
- * @returns {Promise<object|null>} - A promise that resolves to the API response containing the short URL or null if an error occurs.
9
- */
10
- const getShortUrl = async (ndus, path, fid) => {
11
- try {
12
- // API Endpoint
13
- const url = 'https://www.1024terabox.com/share/pset';
14
- const cookies = `ndus=${ndus}`;
3
+ const getShortUrl = async (ndus, path, fid, appId, jsToken, dpLogId) => {
4
+ try {
5
+ const url = `https://www.1024terabox.com/share/pset?app_id=${appId}&jsToken=${jsToken}&dp-logid=${dpLogId}`;
6
+ const cookies = `ndus=${ndus}`;
15
7
 
16
- // Form Data Parameters
17
- const formData = new URLSearchParams({
18
- app_id: '250528',
19
- web: '1',
20
- channel: 'dubox',
21
- clienttype: '0',
22
- app: 'universe',
23
- schannel: '0',
24
- channel_list: '[0]',
25
- period: '0',
26
- path_list: `["${path}"]`,
27
- fid_list: `[${fid}]`,
28
- pwd: '',
29
- public: '1',
30
- scene: ''
31
- });
8
+ const formData = new URLSearchParams({
9
+ app_id: appId,
10
+ web: '1',
11
+ channel: 'dubox',
12
+ clienttype: '0',
13
+ app: 'universe',
14
+ schannel: '0',
15
+ channel_list: '[0]',
16
+ period: '0',
17
+ path_list: `["${path}"]`,
18
+ fid_list: `[${fid}]`,
19
+ pwd: '',
20
+ public: '1',
21
+ scene: ''
22
+ });
32
23
 
33
- // Request Headers
34
- const headers = {
35
- 'Content-Type': 'application/x-www-form-urlencoded',
36
- 'Cookie': cookies,
37
- 'Referer': 'https://www.1024terabox.com/',
38
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
39
- };
24
+ const headers = {
25
+ 'Content-Type': 'application/x-www-form-urlencoded',
26
+ 'Cookie': cookies,
27
+ 'Referer': 'https://www.1024terabox.com/',
28
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
29
+ };
40
30
 
41
- // Send POST request to generate a short URL
42
- const response = await axios.post(url, formData.toString(), { headers });
43
-
44
- // Return the API response containing the short URL
45
- return response.data;
46
- } catch (error) {
47
- console.error('Error generating short link:', error);
48
- return null;
49
- }
31
+ const response = await axios.post(url, formData.toString(), { headers });
32
+ return response.data;
33
+ } catch (error) {
34
+ return null;
35
+ }
50
36
  };
51
37
 
52
38
  module.exports = getShortUrl;
@@ -1,41 +1,21 @@
1
- /**
2
- * Builds the URL for uploading a file chunk.
3
- * @param {string} fileName - The name of the file being uploaded
4
- * @param {string} uploadId - The unique ID for the upload session (optional)
5
- * @param {string} appId - The application ID (required)
6
- * @returns {string} - The upload URL
7
- */
1
+ function buildPrecreateUrl(appId, jsToken, dpLogId) {
2
+ return `https://www.1024terabox.com/api/precreate?app_id=${appId}&web=1&channel=dubox&clienttype=0&jsToken=${jsToken}&dp-logid=${dpLogId}`;
3
+ }
4
+
8
5
  function buildUploadUrl(fileName, uploadId, appId) {
9
6
  return `https://c-jp.1024terabox.com/rest/2.0/pcs/superfile2?method=upload&app_id=${appId}&channel=dubox&clienttype=0&web=1&path=%2F${encodeURIComponent(fileName)}&uploadid=${uploadId}&uploadsign=0&partseq=0`;
10
7
  }
11
8
 
12
- /**
13
- * Builds the URL for the final create call.
14
- * @returns {string} - The create URL
15
- */
16
- function buildCreateUrl() {
17
- return 'https://www.1024terabox.com/api/create';
9
+ function buildCreateUrl(appId, jsToken, dpLogId) {
10
+ return `https://www.1024terabox.com/api/create?app_id=${appId}&web=1&channel=dubox&clienttype=0&jsToken=${jsToken}&dp-logid=${dpLogId}`;
18
11
  }
19
12
 
20
- /**
21
- * Builds the URL for fetching the file list.
22
- * @param {string} appId - The application ID
23
- * @param {string} directory - The directory path to fetch the file list from
24
- * @returns {string} - The file list URL
25
- */
26
- function buildListUrl(appId, directory) {
27
- return `https://www.1024terabox.com/api/list?app_id=${appId}&web=1&channel=dubox&clienttype=0&order=time&desc=1&dir=${encodeURIComponent(directory)}&num=100&page=1&showempty=0`;
13
+ function buildListUrl(appId, directory, jsToken, dpLogId) {
14
+ return `https://www.1024terabox.com/api/list?app_id=${appId}&web=1&channel=dubox&clienttype=0&jsToken=${jsToken}&dp-logid=${dpLogId}&order=time&desc=1&dir=${encodeURIComponent(directory)}&num=100&page=1&showempty=0`;
28
15
  }
29
16
 
30
-
31
- /**
32
- * Builds the downloadable link for videos.
33
- * @param {string} appId - The application ID
34
- * @param {string} videoPath - The directory path to fetch the file list from
35
- * @returns {string} - The file list URL
36
- */
37
17
  function buildVideoDownloadUrl(appId, videoPath) {
38
18
  return `https://www.1024terabox.com/api/streaming?path=${encodeURIComponent(videoPath)}&app_id=${appId}&clienttype=0&type=M3U8_FLV_264_480&vip=1`;
39
19
  }
40
20
 
41
- module.exports = { buildUploadUrl, buildCreateUrl, buildListUrl, buildVideoDownloadUrl };
21
+ module.exports = { buildPrecreateUrl, buildUploadUrl, buildCreateUrl, buildListUrl, buildVideoDownloadUrl };
package/lib/index.js CHANGED
@@ -1,234 +1,168 @@
1
1
  const axios = require('axios');
2
2
  const path = require('path');
3
3
  const fs = require('fs');
4
+ const crypto = require('crypto');
4
5
  const FormData = require('form-data');
5
- const { buildUploadUrl, buildCreateUrl, buildListUrl } = require('./helpers/utils');
6
+ const {
7
+ buildPrecreateUrl,
8
+ buildUploadUrl,
9
+ buildCreateUrl,
10
+ buildListUrl,
11
+ } = require('./helpers/utils');
6
12
  const getDownloadLink = require('./helpers/download/download');
7
13
  const { deleteFile } = require('./helpers/fileDelete');
8
14
  const { moveFile } = require('./helpers/fileMove');
9
15
  const getShortUrl = require('./helpers/getShortUrl');
10
16
 
11
- /**
12
- * Class to handle Terabox file operations
13
- */
14
17
  class TeraboxUploader {
15
18
  constructor(credentials) {
16
- // Now require jsToken and browserId for deletion functionality
17
- if (
18
- !credentials ||
19
- !credentials.ndus ||
20
- !credentials.appId ||
21
- !credentials.uploadId ||
22
- !credentials.jsToken ||
23
- !credentials.browserId
24
- ) {
25
- throw new Error("Credentials are required (ndus, appId, uploadId, jsToken, browserId).");
19
+ if (!credentials || !credentials.ndus || !credentials.appId || !credentials.jsToken) {
20
+ throw new Error('Credentials are required (ndus, appId, jsToken).');
26
21
  }
27
22
 
28
23
  this.credentials = {
29
24
  ndus: credentials.ndus,
30
- cookies: `browserid=3BeB9xGWg2yuzOuPRnKtO0ZQx990OtItXpdwkRVAIKYiLxBkT8yVYM3TnVr=; lang=en; ndus=${credentials.ndus};`,
25
+ cookies: `lang=en; ndus=${credentials.ndus};`,
31
26
  appId: credentials.appId,
32
- uploadId: credentials.uploadId,
33
27
  jsToken: credentials.jsToken,
34
- browserId: credentials.browserId,
28
+ bdstoken: credentials.bdstoken || '',
29
+ browserId: credentials.browserId || '',
30
+ dpLogId: credentials.dpLogId || this._generateDpLogId(),
35
31
  };
36
32
  }
37
33
 
38
- /**
39
- * Uploads a file to Terabox
40
- * @param {string} filePath - Path to the file to be uploaded
41
- * @param {function} progressCallback - Optional callback to track upload progress
42
- * @param {string} [directory='/'] - Optional directory where the file will be saved on Terabox
43
- * @returns {Promise<{success: boolean, message: string, fileDetails?: object}>} - A promise that resolves to an object indicating the result of the upload:
44
- * - `success` (boolean): `true` if the upload was successful, `false` otherwise.
45
- * - `message` (string): A message with the upload status (success or error).
46
- * - `fileDetails` (optional object): The details of the file uploaded, returned only if the upload was successful.
47
- */
34
+ _generateDpLogId() {
35
+ return crypto.randomBytes(10).toString('hex').toUpperCase();
36
+ }
37
+
48
38
  async uploadFile(filePath, progressCallback, directory = '/') {
49
39
  try {
50
40
  const fileName = path.basename(filePath);
51
- const fileSize = fs.statSync(filePath).size;
52
- const uploadUrl = buildUploadUrl(fileName, this.credentials.uploadId, this.credentials.appId);
41
+ const stats = fs.statSync(filePath);
42
+ const fileSize = stats.size;
43
+ const fileMd5 = crypto.createHash('md5').update(fs.readFileSync(filePath)).digest('hex');
44
+
45
+ const precreateUrl = buildPrecreateUrl(this.credentials.appId, this.credentials.jsToken, this.credentials.dpLogId);
46
+ const precreateResponse = await axios.post(
47
+ precreateUrl,
48
+ new URLSearchParams({
49
+ path: `${directory}/${fileName}`,
50
+ autoinit: '1',
51
+ target_path: directory,
52
+ block_list: JSON.stringify([fileMd5]),
53
+ size: fileSize,
54
+ local_mtime: Math.floor(stats.mtimeMs / 1000),
55
+ }).toString(),
56
+ { headers: { 'Content-Type': 'application/x-www-form-urlencoded', Cookie: this.credentials.cookies } }
57
+ );
53
58
 
54
- // Preflight request (OPTIONS)
55
- await axios.options(uploadUrl, { headers: { Origin: 'https://www.1024terabox.com' } });
59
+ if (precreateResponse.data.errno !== 0) {
60
+ throw new Error(`Precreate failed: ${precreateResponse.data.errmsg || 'Unknown error'}`);
61
+ }
56
62
 
57
- // Upload the file as form data (POST)
63
+ const uploadId = precreateResponse.data.uploadid;
64
+ const uploadUrl = buildUploadUrl(fileName, uploadId, this.credentials.appId);
58
65
  const formData = new FormData();
59
66
  formData.append('file', fs.createReadStream(filePath));
60
67
 
61
- const postResponse = await axios.post(uploadUrl, formData, {
62
- headers: {
63
- ...formData.getHeaders(),
64
- Origin: 'https://www.1024terabox.com',
65
- Cookie: this.credentials.cookies,
66
- },
67
- onUploadProgress: (progressEvent) => {
68
- if (progressCallback) {
69
- progressCallback(progressEvent.loaded, progressEvent.total);
70
- }
71
- },
68
+ await axios.post(uploadUrl, formData, {
69
+ headers: { ...formData.getHeaders(), Cookie: this.credentials.cookies },
70
+ onUploadProgress: (e) => progressCallback && progressCallback(e.loaded, e.total),
72
71
  });
73
72
 
74
- // Finalize the upload (Create call)
75
- const createUrl = buildCreateUrl();
76
- const createResponse = await axios.post(
77
- createUrl,
78
- new URLSearchParams({
79
- path: `${directory}/${fileName}`,
80
- size: fileSize,
81
- uploadid: this.credentials.uploadId,
82
- target_path: directory,
83
- block_list: JSON.stringify([postResponse.headers['content-md5']]),
84
- local_mtime: Math.floor(Date.now() / 1000),
85
- }).toString(),
86
- {
87
- headers: {
88
- 'Content-Type': 'application/x-www-form-urlencoded',
89
- Cookie: this.credentials.cookies,
90
- },
91
- }
92
- );
73
+ const createUrl = buildCreateUrl(this.credentials.appId, this.credentials.jsToken, this.credentials.dpLogId);
74
+ const createParams = new URLSearchParams({
75
+ path: `${directory}/${fileName}`,
76
+ size: fileSize,
77
+ uploadid: uploadId,
78
+ target_path: directory,
79
+ block_list: JSON.stringify([fileMd5]),
80
+ local_mtime: Math.floor(stats.mtimeMs / 1000),
81
+ isdir: '0',
82
+ rtype: '1',
83
+ });
84
+ if (this.credentials.bdstoken) createParams.append('bdstoken', this.credentials.bdstoken);
93
85
 
94
- // Return success message
95
- return {
96
- success: true,
97
- message: 'File uploaded successfully.',
98
- fileDetails: createResponse.data,
99
- };
100
- } catch (error) {
86
+ const createResponse = await axios.post(createUrl, createParams.toString(), {
87
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded', Cookie: this.credentials.cookies },
88
+ });
101
89
 
102
- // Return failure message
103
- return {
104
- success: false,
105
- message: error.response?.data || error.message,
106
- };
90
+ return { success: true, message: 'File uploaded successfully.', fileDetails: createResponse.data };
91
+ } catch (error) {
92
+ return { success: false, message: error.response?.data || error.message };
107
93
  }
108
94
  }
109
95
 
110
- /**
111
- * Fetches the file list from Terabox
112
- * @param {string} directory - Directory to fetch the file list from (e.g., "/")
113
- * @returns {Promise<object>} - JSON response with file details along with download link
114
- */
115
- async fetchFileList(directory = '/') {
96
+ async createDirectory(directoryPath) {
116
97
  try {
117
- const listUrl = buildListUrl(this.credentials.appId, directory);
98
+ const createUrl = buildCreateUrl(this.credentials.appId, this.credentials.jsToken, this.credentials.dpLogId);
99
+ const createParams = new URLSearchParams({
100
+ path: directoryPath,
101
+ isdir: '1',
102
+ size: '0',
103
+ block_list: '[]',
104
+ local_mtime: Math.floor(Date.now() / 1000),
105
+ });
106
+ if (this.credentials.bdstoken) createParams.append('bdstoken', this.credentials.bdstoken);
118
107
 
119
- const response = await axios.get(listUrl, {
120
- headers: {
121
- Cookie: this.credentials.cookies,
122
- },
108
+ const response = await axios.post(createUrl, createParams.toString(), {
109
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded', Cookie: this.credentials.cookies },
123
110
  });
111
+ return { success: true, message: 'Directory created successfully.', data: response.data };
112
+ } catch (error) {
113
+ return { success: false, message: error.response?.data || error.message };
114
+ }
115
+ }
124
116
 
117
+ async fetchFileList(directory = '/') {
118
+ try {
119
+ const listUrl = buildListUrl(this.credentials.appId, directory, this.credentials.jsToken, this.credentials.dpLogId);
120
+ const response = await axios.get(listUrl, { headers: { Cookie: this.credentials.cookies } });
125
121
  return { success: true, message: 'File list retrieved successfully.', data: response.data };
126
122
  } catch (error) {
127
- console.error('Error fetching file list:', error);
128
- return {
129
- success: false,
130
- message: error.response?.data?.error || error.message || 'Failed to fetch file list.',
131
- };
123
+ return { success: false, message: error.response?.data?.error || error.message };
132
124
  }
133
125
  }
134
126
 
135
- /**
136
- * Uploads a file to Terabox
137
- * @param {int} fileId - fs_id in file details
138
- * @returns {Promise<{success: boolean, message: string, fileDetails?: object}>} - A promise that resolves to an object with download link.
139
- */
140
127
  async downloadFile(fileId) {
141
128
  try {
142
- const ndus = this.credentials.ndus;
143
- const fid = fileId;
144
- const response = await getDownloadLink(ndus, fid);
145
- return response
129
+ const { ndus, appId, jsToken, dpLogId } = this.credentials;
130
+ return await getDownloadLink(ndus, fileId, appId, jsToken, dpLogId);
146
131
  } catch (error) {
147
- return {
148
- success: false,
149
- message: error.response?.data?.error || error.message || 'Failed to fetch file list.',
150
- };
132
+ return { success: false, message: error.response?.data?.error || error.message };
151
133
  }
152
134
  }
153
135
 
154
- /**
155
- * Deletes files from Terabox using the deletion API.
156
- * @param {Array} fileList - List of file paths to be deleted on Terabox
157
- * @returns {Promise<any>} - A promise that resolves to the deletion result.
158
- */
159
136
  async deleteFiles(fileList) {
160
137
  try {
161
- const config = {
162
- ndus: this.credentials.ndus,
163
- appId: this.credentials.appId,
164
- jsToken: this.credentials.jsToken,
165
- browserId: this.credentials.browserId,
166
- };
138
+ const config = { ...this.credentials };
167
139
  const result = await deleteFile(fileList, config);
168
140
  return { success: true, message: 'Files deleted successfully.', result };
169
141
  } catch (error) {
170
- return {
171
- success: false,
172
- message: error.response?.data?.error || error.message || 'Failed to delete files.',
173
- };
142
+ return { success: false, message: error.response?.data?.error || error.message };
174
143
  }
175
144
  }
176
145
 
177
- /**
178
- * Moves files on Terabox using the move API.
179
- * Moves a file from one location to another with a new name.
180
- * @param {string} sourcePath - The current path of the file.
181
- * @param {string} destinationPath - The destination directory where the file will be moved.
182
- * @param {string} newName - The new name for the file.
183
- * @returns {Promise<any>} - A promise that resolves to the move result.
184
- */
185
146
  async moveFiles(sourcePath, destinationPath, newName) {
186
147
  try {
187
- const config = {
188
- ndus: this.credentials.ndus,
189
- appId: this.credentials.appId,
190
- jsToken: this.credentials.jsToken,
191
- browserId: this.credentials.browserId,
192
- };
193
- // Create file list for move operation as per API: [{"path":"/b","dest":"/a","newname":"c"}]
194
- const fileList = [{
195
- path: sourcePath,
196
- dest: destinationPath,
197
- newname: newName
198
- }];
199
- const result = await moveFile(fileList, config);
200
- return result;
148
+ const config = { ...this.credentials };
149
+ const fileList = [{ path: sourcePath, dest: destinationPath, newname: newName }];
150
+ return await moveFile(fileList, config);
201
151
  } catch (error) {
202
152
  throw error;
203
153
  }
204
154
  }
205
155
 
206
- /**
207
- * Generates a short URL for a file on Terabox
208
- * @param {string} filePath - The file path on Terabox
209
- * @param {string} fileId - The file ID on Terabox
210
- * @returns {Promise<object>} - The API response containing the short URL
211
- */
212
156
  async generateShortUrl(filePath, fileId) {
213
157
  try {
214
- const shortUrlResponse = await getShortUrl(this.credentials.ndus, filePath, fileId);
215
- if (shortUrlResponse && shortUrlResponse.errno === 0) {
216
- return {
217
- success: true,
218
- message: 'Short URL generated successfully.',
219
- shortUrl: shortUrlResponse.shorturl,
220
- };
221
- } else {
222
- return {
223
- success: false,
224
- message: shortUrlResponse?.errmsg || 'Failed to generate short URL.',
225
- };
158
+ const { ndus, appId, jsToken, dpLogId } = this.credentials;
159
+ const res = await getShortUrl(ndus, filePath, fileId, appId, jsToken, dpLogId);
160
+ if (res && res.errno === 0) {
161
+ return { success: true, message: 'Short URL generated successfully.', shortUrl: res.shorturl };
226
162
  }
163
+ return { success: false, message: res?.errmsg || 'Failed to generate short URL.' };
227
164
  } catch (error) {
228
- return {
229
- success: false,
230
- message: error.message || 'An error occurred while generating the short URL.',
231
- };
165
+ return { success: false, message: error.message };
232
166
  }
233
167
  }
234
168
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terabox-upload-tool",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "description": "A robust library designed for seamless integration with TeraBox, the leading cloud storage service offering 1 TB of free space. Effortlessly upload files, download files, delete files, manage directories, and retrieve file lists. Ideal for developers seeking efficient cloud storage solutions within their Node.js projects.",
5
5
  "repository": {
6
6
  "type": "git",
package/test_all.js ADDED
@@ -0,0 +1,79 @@
1
+ const TeraboxUploader = require('./lib/index');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ if (fs.existsSync('.env')) {
6
+ const envFile = fs.readFileSync('.env', 'utf8');
7
+ envFile.split('\n').forEach(line => {
8
+ const [key, ...valueParts] = line.split('=');
9
+ if (key && valueParts.length > 0) {
10
+ const value = valueParts.join('=').trim();
11
+ process.env[key.trim()] = value;
12
+ if (value.includes('ndus=')) {
13
+ const match = value.match(/ndus=([^;]+)/);
14
+ if (match && match[1]) process.env.ndus = match[1];
15
+ }
16
+ }
17
+ });
18
+ }
19
+
20
+ const credentials = {
21
+ ndus: process.env.TERABOX_NDUS || process.env.ndus || 'YOUR_NDUS',
22
+ appId: process.env.TERABOX_APPID || process.env.appId || '250528',
23
+ jsToken: process.env.TERABOX_JSTOKEN || process.env.jsToken || 'YOUR_JS_TOKEN',
24
+ bdstoken: process.env.TERABOX_BDSTOKEN || process.env.bdstoken || '',
25
+ browserId: process.env.TERABOX_BROWSERID || process.env.browserId || ''
26
+ };
27
+
28
+ async function runTest() {
29
+ if (credentials.ndus === 'YOUR_NDUS' || credentials.jsToken === 'YOUR_JS_TOKEN') {
30
+ console.log('Skipping real API tests: Credentials not provided.');
31
+ return;
32
+ }
33
+
34
+ const uploader = new TeraboxUploader(credentials);
35
+ const testFileName = 'test_file.txt';
36
+ const testFilePath = path.join(__dirname, testFileName);
37
+ const testDirPath = '/test_dir_' + Date.now();
38
+
39
+ try {
40
+ fs.writeFileSync(testFilePath, 'Hello Terabox! This is a test file.');
41
+
42
+ console.log('--- Testing createDirectory ---');
43
+ const createDirRes = await uploader.createDirectory(testDirPath);
44
+ console.log('Result:', createDirRes.success ? 'Success' : 'Failed');
45
+
46
+ console.log('--- Testing uploadFile ---');
47
+ const uploadRes = await uploader.uploadFile(testFilePath, null, testDirPath);
48
+ console.log('Result:', uploadRes.success ? 'Success' : 'Failed');
49
+
50
+ if (uploadRes.success) {
51
+ const fsId = uploadRes.fileDetails.fs_id;
52
+ const remotePath = uploadRes.fileDetails.path || `${testDirPath}/${testFileName}`;
53
+
54
+ console.log('--- Testing fetchFileList ---');
55
+ const listRes = await uploader.fetchFileList(testDirPath);
56
+ console.log('Result:', listRes.success ? 'Success' : 'Failed');
57
+
58
+ console.log('--- Testing downloadFile ---');
59
+ const downloadRes = await uploader.downloadFile(fsId);
60
+ console.log('Result:', downloadRes.success ? 'Success' : 'Failed');
61
+
62
+ console.log('--- Testing generateShortUrl ---');
63
+ const shortUrlRes = await uploader.generateShortUrl(remotePath, fsId);
64
+ console.log('Result:', shortUrlRes.success ? 'Success' : 'Failed');
65
+
66
+ console.log('--- Testing moveFiles ---');
67
+ const moveRes = await uploader.moveFiles(remotePath, testDirPath, 'moved_test_file.txt');
68
+ console.log('Result:', moveRes.errno === 0 ? 'Success' : 'Failed');
69
+ }
70
+
71
+ console.log('--- Final Cleanup skipped. Files remain in:', testDirPath);
72
+ } catch (error) {
73
+ console.error('Test failed:', error.message);
74
+ } finally {
75
+ if (fs.existsSync(testFilePath)) fs.unlinkSync(testFilePath);
76
+ }
77
+ }
78
+
79
+ runTest();
@@ -1,27 +0,0 @@
1
- function createFolder(パス, bdstoken, app_id, jsToken) {
2
- const url = `https://www.terabox.com/api/create?a=commit&bdstoken=${bdstoken}&app_id=${app_id}&web=1&channel=dubox&clienttype=0&jsToken=${jsToken}&dp-logid=46452600984514820032`;
3
-
4
- const data = new URLSearchParams({
5
- path: パス,
6
- isdir: 1,
7
- block_list: "[]"
8
- });
9
-
10
- fetch(url, {
11
- method: 'POST',
12
- headers: {
13
- 'Content-Type': 'application/x-www-form-urlencoded',
14
- },
15
- body: data.toString(),
16
- })
17
- .then(response => response.json())
18
- .then(data => {
19
- console.log('Success:', data);
20
- })
21
- .catch((error) => {
22
- console.error('Error:', error);
23
- });
24
- }
25
-
26
- // 使用例
27
- createFolder("/a", "43bfe2c66a09d4e4561d68d6f4f10340", "250528", "3F3649BB89A2A6A09BB50936F9C72BF1D8AD957C2C90DFD89F8213A3150FB8BCCDEB94CC4F3F3D863287FE9BCA60922AF06C81F36045A823C1DD16CF69961185");