How to import database through site?

@rinshulgoel
try before the fetch:

let fileUrl = "https://43987a14-c90a-456c-8939-5e2c96ce2274.usrfiles.com/ugd/" + uploadedFile.url.split("/")[3];
return fetch(fileUrl);

You’re welcome :slight_smile: OK. I will post the final code here:

import wixData from 'wix-data';
import {fetch} from 'wix-fetch';
export function uploadButton1_change(event) {
if($w("#uploadButton1").value.length > 0) {
$w("#uploadButton1").startUpload()
.then(uploadedFile =>  {
let fileUrl = "https://43987a14-c90a-456c-8939-5e2c96ce2274.usrfiles.com/ugd/" + uploadedFile.url.split("/")[3];
return fetch(fileUrl);
})
.then(r => r.text()).then(r => {
let lines = r.split("\n");
let result = [];
let headers = lines[0].split(",");
for(let i = 1; i < lines.length; i++){
let obj = {};
let currentline = lines[i].split(",");

 for(let j = 0; j < headers.length; j++){
          obj[headers[j]] = currentline[j];
      }
      result.push(obj);
  }

// Also here can we add a progress bar so that one could know that is the data insterted or not. As after this it takes a long time to get data imported which is normal.

 return wixData.bulkInsert("Try", result);})
    .then(r => console.log(r))
    .catch(err => err);
}
}