當我將圖像數據編碼爲base64字符串時,我使用服務器文件路徑獲取fs.readFile()
的圖像數據。我有問題:這是否意味着其他人可以解碼base64字符串,然後從編碼數據獲取服務器路徑如下?base64編碼圖像主機url或服務器文件路徑
...
fs.readFile(destinationFilePath, function(error, data){
fulfill(data.toString('base64'));
});
我不想泄露我的服務器路徑,所以我也試過編碼主機URL像下面的代碼,我不知道要使用的base64這個正確的方式?我沒有得到任何的錯誤,但也沒有得到任何迴應 - 我錯過了什麼?
var base64EncodeData = function(destinationFilePath) {
return new Promise(function (fulfill, reject){
var request = require('request').defaults({ encoding: null });
request.get(destinationFilePath, function (error, response, body) {
if (!error && response.statusCode == 200) {
data = "data:" + response.headers["content-type"] + ";base64," + new Buffer(body).toString('base64');
console.log(data);
fulfill(data);
}
});
});
};
如果您編碼這樣的任何東西,您可以複製路徑加密並對其進行解碼。如果你看谷歌,你會發現許多網站將編碼/解碼。如果出於某種原因某人想要找到路徑,可以在幾秒鐘內完成。 https://www.base64decode.org/ – NewToJS