Spaces:
Paused
Paused
Update app.js
Browse files
app.js
CHANGED
|
@@ -12,17 +12,27 @@ const SCOPES = ["https://www.googleapis.com/auth/drive.file"];
|
|
| 12 |
const TOKEN_PATH = "token.json";
|
| 13 |
const CREDENTIALS_PATH = "credentials.json";
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
|
| 28 |
async function getAllRedisData() {
|
|
|
|
| 12 |
const TOKEN_PATH = "token.json";
|
| 13 |
const CREDENTIALS_PATH = "credentials.json";
|
| 14 |
|
| 15 |
+
|
| 16 |
+
const auth = new google.auth.GoogleAuth({
|
| 17 |
+
keyFile: 'credentials.json',
|
| 18 |
+
scopes: ['https://www.googleapis.com/auth/drive.file'],
|
| 19 |
+
});
|
| 20 |
+
|
| 21 |
+
const drive = google.drive({ version: 'v3', auth });
|
| 22 |
+
|
| 23 |
+
async function uploadBackup(filePath, fileName) {
|
| 24 |
+
const res = await drive.files.create({
|
| 25 |
+
requestBody: {
|
| 26 |
+
name: fileName,
|
| 27 |
+
parents: ['FOLDER_ID'], // optional: set your shared folder
|
| 28 |
+
},
|
| 29 |
+
media: {
|
| 30 |
+
mimeType: 'application/json',
|
| 31 |
+
body: fs.createReadStream(filePath),
|
| 32 |
+
},
|
| 33 |
+
});
|
| 34 |
+
|
| 35 |
+
console.log('File uploaded to Google Drive:', res.data);
|
| 36 |
}
|
| 37 |
|
| 38 |
async function getAllRedisData() {
|