2
I have the information from the CSV file on console.log
back-end, I would need to access this file and read its contents, some hint?
This is the code snippet from the back end that receives the file:
exports.anexo = function(req, res){
var arquivo = req.files.uploads;
var date = new Date();
var dateTime = date.getTime();
console.log(arquivo);
var fileList = [];
if(arquivo != undefined){
for(var i=0; i < arquivo.length; i++){
if(arquivo[i].originalFilename != undefined){
var url_arquivo = dateTime + '_' + arquivo[i].originalFilename;
var tipo_arquivo = arquivo[i].type;
var path_origem = arquivo[i].path;
var path_destino = './uploads/' + url_arquivo;
var File = {
url_arquivo: url_arquivo
};
fileList.push(File);
}
}
}
}
And here’s the part of the code on the front end that reads the file and sends it back-end
anexaArquivos(fileList : File[]) : Promise<any> {
console.log('chamou a função no regiao.service')
return new Promise((resolve, reject ) => {
let formData : FormData = new FormData()
let xhr : XMLHttpRequest = new XMLHttpRequest()
if(fileList.length > 0){
for( let i = 0; i < fileList.length; i++){
formData.append("uploads[]", fileList[i], fileList[i].name);
}
}
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
resolve(JSON.parse(xhr.response))
} else {
reject(xhr.response)
}
}
}
xhr.open('POST', `${SES_API}/regiao/importar`, true);
xhr.setRequestHeader('Authorization', `Bearer ${this.userService.sessao.accessToken}`);
xhr.send(formData);
})
}
You have placed a link to a PDF book, in addition to the link being invalid, it is not allowed to distribute material in this way on the site, unless the material is freely distributed. If the book is not available free by the author or publisher, it is piracy and is not allowed on the site.
– user28595
I solved with Filereader and Readastext, but I will search on D3, thanks!!
– Bruno Elias de Souza