@xuda.io/drive_module 1.1.492 → 1.1.494
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/index.js +3 -159
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1503,8 +1503,9 @@ exports.upload_drive_file = async function (req, job_id, headers, file_obj) {
|
|
|
1503
1503
|
return {
|
|
1504
1504
|
code: 760,
|
|
1505
1505
|
data: {
|
|
1506
|
-
server_file_name:
|
|
1506
|
+
server_file_name: file_name,
|
|
1507
1507
|
filename: file_obj.originalname,
|
|
1508
|
+
file_url,
|
|
1508
1509
|
},
|
|
1509
1510
|
};
|
|
1510
1511
|
} catch (err) {
|
|
@@ -1965,10 +1966,6 @@ exports.copy_file_to_another_bucket = async function (
|
|
|
1965
1966
|
})
|
|
1966
1967
|
.promise();
|
|
1967
1968
|
|
|
1968
|
-
// console.log(
|
|
1969
|
-
// `File copied successfully from ${source_region}/${file_name} to ${target_region}/${file_name}`,
|
|
1970
|
-
// ret
|
|
1971
|
-
// );
|
|
1972
1969
|
ret.Location = `${_conf.storage_bucket[target_region].endpoint}/${target_region}/${file_name}`;
|
|
1973
1970
|
ret.key = file_name;
|
|
1974
1971
|
ret.Key = file_name;
|
|
@@ -2094,157 +2091,4 @@ const get_folder_docs = async function (dir, drive_type, app_id) {
|
|
|
2094
2091
|
return docs;
|
|
2095
2092
|
};
|
|
2096
2093
|
|
|
2097
|
-
|
|
2098
|
-
// // Import required libraries
|
|
2099
|
-
// const {
|
|
2100
|
-
// S3Client,
|
|
2101
|
-
// ListObjectsV2Command,
|
|
2102
|
-
// DeleteObjectsCommand,
|
|
2103
|
-
// } = require("@aws-sdk/client-s3");
|
|
2104
|
-
|
|
2105
|
-
// // Configure your DigitalOcean Spaces or S3 details
|
|
2106
|
-
|
|
2107
|
-
// const SPACE_NAME = "dev.xuda.io";
|
|
2108
|
-
// const FOLDER_PATH = "/workspace/prj3937cb6f9a31c8c7dea25055bba845b1"; // The key of the file you want to delete
|
|
2109
|
-
|
|
2110
|
-
// const s3Client = new S3Client({
|
|
2111
|
-
// region: _conf.storage_bucket[process.env.XUDA_HOSTNAME].region,
|
|
2112
|
-
// endpoint: _conf.storage_bucket[process.env.XUDA_HOSTNAME].endpoint,
|
|
2113
|
-
// credentials: {
|
|
2114
|
-
// accessKeyId: _conf.digitalocean.spaces_access_key,
|
|
2115
|
-
// secretAccessKey: _conf.digitalocean.spaces_secret_key,
|
|
2116
|
-
// },
|
|
2117
|
-
// });
|
|
2118
|
-
|
|
2119
|
-
// // Function to delete a folder
|
|
2120
|
-
// async function deleteFolder() {
|
|
2121
|
-
// try {
|
|
2122
|
-
// // List all objects in the folder
|
|
2123
|
-
// const listedObjects = await s3Client.send(
|
|
2124
|
-
// new ListObjectsV2Command({
|
|
2125
|
-
// Bucket: SPACE_NAME,
|
|
2126
|
-
// // Prefix: FOLDER_PATH,
|
|
2127
|
-
// })
|
|
2128
|
-
// );
|
|
2129
|
-
// debugger;
|
|
2130
|
-
// if (listedObjects.Contents.length === 0) return;
|
|
2131
|
-
|
|
2132
|
-
// // Prepare a list of objects to delete
|
|
2133
|
-
// const deleteParams = {
|
|
2134
|
-
// Bucket: SPACE_NAME,
|
|
2135
|
-
// Delete: { Objects: [] },
|
|
2136
|
-
// };
|
|
2137
|
-
|
|
2138
|
-
// listedObjects.Contents.forEach(({ Key }) => {
|
|
2139
|
-
// deleteParams.Delete.Objects.push({ Key });
|
|
2140
|
-
// });
|
|
2141
|
-
|
|
2142
|
-
// // Delete the objects
|
|
2143
|
-
// await s3Client.send(new DeleteObjectsCommand(deleteParams));
|
|
2144
|
-
|
|
2145
|
-
// // Check if there are more objects to delete (pagination)
|
|
2146
|
-
// if (listedObjects.IsTruncated) await deleteFolder();
|
|
2147
|
-
// } catch (err) {
|
|
2148
|
-
// console.log("Error", err);
|
|
2149
|
-
// }
|
|
2150
|
-
// }
|
|
2151
|
-
|
|
2152
|
-
// // Call the function to delete the folder
|
|
2153
|
-
// deleteFolder();
|
|
2154
|
-
|
|
2155
|
-
// // return
|
|
2156
|
-
// // const { S3Client, DeleteObjectCommand } = require("@aws-sdk/client-s3");
|
|
2157
|
-
|
|
2158
|
-
// // // Configure your DigitalOcean Spaces details
|
|
2159
|
-
|
|
2160
|
-
// // const SPACE_NAME = "dev.xuda.io";
|
|
2161
|
-
// // const FILE_KEY = "workspace/prj3937cb6f9a31c8c7dea25055bba845b1/"; // The key of the file you want to delete
|
|
2162
|
-
|
|
2163
|
-
// // // Create an S3 client
|
|
2164
|
-
// // const s3Client = new S3Client({
|
|
2165
|
-
// // region: _conf.storage_bucket[process.env.XUDA_HOSTNAME].region,
|
|
2166
|
-
// // endpoint: _conf.storage_bucket[process.env.XUDA_HOSTNAME].endpoint,
|
|
2167
|
-
// // credentials: {
|
|
2168
|
-
// // accessKeyId: _conf.digitalocean.spaces_access_key,
|
|
2169
|
-
// // secretAccessKey: _conf.digitalocean.spaces_secret_key,
|
|
2170
|
-
// // },
|
|
2171
|
-
// // });
|
|
2172
|
-
|
|
2173
|
-
// // // Function to delete an object
|
|
2174
|
-
// // async function deleteObjectFromSpaces() {
|
|
2175
|
-
// // try {
|
|
2176
|
-
// // const data = await s3Client.send(
|
|
2177
|
-
// // new DeleteObjectCommand({
|
|
2178
|
-
// // Bucket: SPACE_NAME,
|
|
2179
|
-
// // Key: FILE_KEY,
|
|
2180
|
-
// // })
|
|
2181
|
-
// // );
|
|
2182
|
-
// // console.log("Success", data);
|
|
2183
|
-
// // } catch (err) {
|
|
2184
|
-
// // console.log("Error", err);
|
|
2185
|
-
// // }
|
|
2186
|
-
// // }
|
|
2187
|
-
|
|
2188
|
-
// // // Call the function to delete the object
|
|
2189
|
-
// // deleteObjectFromSpaces();
|
|
2190
|
-
|
|
2191
|
-
// // return;
|
|
2192
|
-
// // const AWS = require("aws-sdk");
|
|
2193
|
-
|
|
2194
|
-
// // // Configure the AWS SDK to use DigitalOcean Spaces
|
|
2195
|
-
// // const spacesEndpoint = new AWS.Endpoint(
|
|
2196
|
-
// // _conf.storage_bucket[process.env.XUDA_HOSTNAME].endpoint
|
|
2197
|
-
// // );
|
|
2198
|
-
// // const s3 = new AWS.S3({
|
|
2199
|
-
// // endpoint: spacesEndpoint,
|
|
2200
|
-
// // accessKeyId: _conf.digitalocean.spaces_access_key,
|
|
2201
|
-
// // secretAccessKey: _conf.digitalocean.spaces_secret_key,
|
|
2202
|
-
// // region: _conf.storage_bucket[process.env.XUDA_HOSTNAME].region,
|
|
2203
|
-
// // });
|
|
2204
|
-
|
|
2205
|
-
// // try {
|
|
2206
|
-
// // debugger;
|
|
2207
|
-
|
|
2208
|
-
// // // const params = {
|
|
2209
|
-
// // // Bucket: "dev.xuda.io",
|
|
2210
|
-
// // // };
|
|
2211
|
-
|
|
2212
|
-
// // // s3.listObjectsV2(params, function (err, data) {
|
|
2213
|
-
// // // if (err) console.log(err, err.stack); // an error occurred
|
|
2214
|
-
// // // else console.log(data); // successful response
|
|
2215
|
-
// // // });
|
|
2216
|
-
|
|
2217
|
-
// // const ret = await s3
|
|
2218
|
-
// // .listObjectsV2({
|
|
2219
|
-
// // Bucket: "dev.xuda.io",
|
|
2220
|
-
// // // Prefix: "",
|
|
2221
|
-
// // })
|
|
2222
|
-
// // .promise();
|
|
2223
|
-
|
|
2224
|
-
// // // const ret = await s3.send(
|
|
2225
|
-
// // // new ListObjectsV2Command({
|
|
2226
|
-
// // // Bucket: "dev.xuda.io",
|
|
2227
|
-
// // // Prefix: "workspace/",
|
|
2228
|
-
// // // // ContinuationToken: continuationToken,
|
|
2229
|
-
// // // })
|
|
2230
|
-
// // // );
|
|
2231
|
-
|
|
2232
|
-
// // console.log(ret);
|
|
2233
|
-
|
|
2234
|
-
// // // for await (let [key, val] of Object.entries(_conf.storage_bucket)) {
|
|
2235
|
-
// // // const ret = await s3
|
|
2236
|
-
// // // .listObjectsV2({
|
|
2237
|
-
// // // Bucket: key,
|
|
2238
|
-
// // // Prefix: "/",
|
|
2239
|
-
// // // })
|
|
2240
|
-
// // // .promise();
|
|
2241
|
-
// // // console.log(ret);
|
|
2242
|
-
// // // }
|
|
2243
|
-
// // // return data;
|
|
2244
|
-
// // } catch (err) {
|
|
2245
|
-
// // console.error("Error", err);
|
|
2246
|
-
// // }
|
|
2247
|
-
// };
|
|
2248
|
-
setTimeout(function () {
|
|
2249
|
-
// exports.delete_folder_from_bucket();
|
|
2250
|
-
}, 2000);
|
|
2094
|
+
setTimeout(function () {}, 2000);
|