Removing Container Name from Paths

This commit is contained in:
Luis Fernando Molina committed 2020-01-28 13:28:54 +01:00
1 parent 797fb06544
commit 1909e8c54f
3 files changed
+4 -64

No files matched your search

-54
View File
@@ -1,54 +0,0 @@
function newFileStorage() {
const MODULE_NAME = 'File Cloud'
const INFO_LOG = false
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
thisObject = {
getBlobToText: getBlobToText
};
return thisObject;
function getBlobToText(pContainerName, pPath, callBackFunction) {
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
try {
let response = JSON.parse(xhttp.responseText);
callBackFunction(response.err, response.text, "");
} catch (err) {
if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[ERROR] AppPreLoader -> getBlobToText -> Invalid JSON received. "); }
if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[ERROR] AppPreLoader -> getBlobToText -> response.text = " & response.text); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE, "", "");
}
}
};
try {
let request = {
conatinerName: pContainerName,
path: pPath
};
request = JSON.stringify(request);
let path = "FileService";
let blob = new Blob([request], { type: 'text/plain' });
xhttp.open("GET", path, true);
xhttp.send(blob);
} catch (err) {
if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[ERROR] getBlobToText -> err.message = " & err.message); }
}
}
}
+1 -7
View File
@@ -119,11 +119,7 @@ function newFileCloud () {
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> filePath = ' + filePath) }
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> fileName = ' + fileName) }
let containerName
containerName = pDataMine.code.codeName.toLowerCase()
blobService.getBlobToText(containerName, filePath + '/' + fileName, undefined, onFileReceived)
blobService.getBlobToText(filePath + '/' + fileName, undefined, onFileReceived)
function onFileReceived (err, text, response) {
try {
@@ -146,7 +142,6 @@ function newFileCloud () {
return
}
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> containerName = ' + containerName) }
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> filePath = ' + filePath) }
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> fileName = ' + fileName) }
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> Unexpected Error Ocurred.') }
@@ -181,7 +176,6 @@ function newFileCloud () {
return
} catch (err) {
if (ERROR_LOG === true) { logger.write('[WARN] getFile -> getFileRecursively -> onFileReceived -> err = ' + err.stack) }
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> containerName = ' + containerName) }
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> filePath = ' + filePath) }
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> fileName = ' + fileName) }
+3 -3
View File
@@ -29,11 +29,11 @@ function newFileStorage () {
return thisObject
async function getBlobToText (container, filePath, host, callBackFunction) {
async function getBlobToText (filePath, host, callBackFunction) {
try {
if (INFO_LOG === true) { logger.write('[INFO] getBlobToText -> Entering function.') }
callServer(undefined, 'Storage/' + container + '/' + filePath, (response, fileContent) => {
callServer(undefined, 'Storage/' + filePath, (response, fileContent) => {
if (response.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, fileContent)
} else {
@@ -44,7 +44,7 @@ function newFileStorage () {
if (verifyRetry(err.code) && currentRetry < MAX_RETRY) {
currentRetry++
if (INFO_LOG === true) { console.log('[INFO] getTextFile -> Retrying connection to the server because received error: ' + err.code + '. Retry #: ' + currentRetry) }
getBlobToText(container, filePath, host, callBackFunction)
getBlobToText(filePath, host, callBackFunction)
} else if (err.message === 'Request aborted') {
let err = { code: 'The specified key does not exist.' }
callBackFunction(err)