CloudStorage + ClientSettings Saving!

This commit is contained in:
Lawin0129
2021-11-16 21:53:55 +00:00
committed by GitHub
parent 6e3cdd554e
commit 43e52b3625

View File

@@ -725,10 +725,47 @@ express.get("/fortnite/api/cloudstorage/system", async (req, res) => {
const seasonchecker = require("./seasonchecker.js"); const seasonchecker = require("./seasonchecker.js");
const seasondata = require("./season.json"); const seasondata = require("./season.json");
seasonchecker(req, seasondata); seasonchecker(req, seasondata);
if (seasondata.season > 9) { if (seasondata.season == 10) {
return res.status(404).json(); return res.status(404).json();
} }
res.json([])
const dir = path.join(__dirname, 'CloudStorage')
var CloudFiles = [];
fs.readdirSync(dir).forEach(name => {
if (name.toLowerCase().endsWith(".ini")) {
const ParsedFile = fs.readFileSync(path.join(__dirname, 'CloudStorage', name));
const ParsedStats = fs.statSync(path.join(__dirname, 'CloudStorage', name));
CloudFiles.push({
"uniqueFilename": name,
"filename": name,
"hash": crypto.createHash('sha1').update(ParsedFile).digest('hex'),
"hash256": crypto.createHash('sha256').update(ParsedFile).digest('hex'),
"length": ParsedFile.length,
"contentType": "application/octet-stream",
"uploaded": ParsedStats.mtime,
"storageType": "S3",
"storageIds": {},
"doNotCache": true
})
}
});
res.json(CloudFiles)
res.status(200);
res.end();
})
express.get("/fortnite/api/cloudstorage/system/:file", async (req, res) => {
const file = path.join(__dirname, 'CloudStorage', req.params.file);
if (fs.existsSync(file)) {
const ParsedFile = fs.readFileSync(file);
return res.status(200).send(ParsedFile).end();
}
res.status(200); res.status(200);
res.end(); res.end();
}) })
@@ -792,6 +829,7 @@ express.get("/fortnite/api/cloudstorage/user/:accountId", async (req, res) => {
if (fs.existsSync(file)) { if (fs.existsSync(file)) {
const utf8_file = fs.readFileSync(path.join(__dirname, file), 'utf8'); const utf8_file = fs.readFileSync(path.join(__dirname, file), 'utf8');
const file_stats = fs.statSync(path.join(__dirname, file));
return res.status(200).json([{ return res.status(200).json([{
"uniqueFilename": "ClientSettings.Sav", "uniqueFilename": "ClientSettings.Sav",
@@ -800,10 +838,11 @@ express.get("/fortnite/api/cloudstorage/user/:accountId", async (req, res) => {
"hash256": crypto.createHash('sha256').update(utf8_file).digest('hex'), "hash256": crypto.createHash('sha256').update(utf8_file).digest('hex'),
"length": Buffer.byteLength(utf8_file), "length": Buffer.byteLength(utf8_file),
"contentType": "application/octet-stream", "contentType": "application/octet-stream",
"uploaded": new Date().toISOString(), "uploaded": file_stats.mtime,
"storageType": "S3", "storageType": "S3",
"storageIds": {}, "storageIds": {},
"accountId": req.params.accountId "accountId": req.params.accountId,
"doNotCache": true
}]).end(); }]).end();
} else { } else {
return res.status(200).json([]).end(); return res.status(200).json([]).end();