CSRND
(Ang Fas)
October 24, 2023, 8:19am
1
Hello.
Description
For a logging mechanism log4javascripts creates files in the sandboxed filesystem of chrome. Then we can access it with an xhr request.
e.g. https://ourdomain.com/temporary/logs/logfile20231020091215.log
We do not need to download a file however with this request we get the blob and then we can send it to our backend.
Error?
GET filesystem:https://ourdomain.com/temporary/logs/logfile20231020091215.log 403 (Forbidden)
Is this behavior expected? If yes, is there another way to access the file?
Note: When inspecting the app, if you click open in a new tab the log file is displayed.
Hi, @CSRND ,
Thank you for posting in the Zoom Developer Forum. To start, can you share more details about your use case and also provide a screenshot of the message you are seeing along with code snippets?
CSRND
(Ang Fas)
October 26, 2023, 7:39am
3
Hello @donte.zoom , thank you for your quick response.
The issue is that we store a log file in the temporary storage of the browser and the fetch it with an xhr request.
I do not seem to be able to upload screenshots for some reason but they do not provide much insight.
Here is a snippet for you to test:
var requestedBytes = 16,
_grantedBytes;
function errorHandler(e) {
console.log(e)
}
function getFile(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onreadystatechange = function () {
if (xhr.readyState !== xhr.DONE) {
return;
}
if (xhr.status === 200) {
console.log('success')
} else {
console.log('failure')
}
}
xhr.send();
}
function writeFile(fs) {
console.log(fs)
fs.root.getFile("file.txt", {
create: true
}, function(fileEntry) {
fileEntry.createWriter(function(fileWriter) {
fileWriter.onwriteend = function(e) {
// call `getFile`
console.log(_grantedBytes);
console.log(fileEntry);
console.log(fileEntry.toURL());
getFile(fileEntry.toURL());
};
fileWriter.onerror = errorHandler;
var blob = new Blob(["abc"], {
type: "text/plain"
});
fileWriter.write(blob);
}, errorHandler);
}, errorHandler);
}
navigator.webkitTemporaryStorage.requestQuota(requestedBytes
, function(grantedBytes) {
console.log(grantedBytes);
_grantedBytes = grantedBytes;
window.webkitRequestFileSystem(window.TEMPORARY
, grantedBytes
, writeFile
, errorHandler);
}, errorHandler);