Skip to content

Commit

Permalink
Revert "added fileinput() function"
Browse files Browse the repository at this point in the history
This reverts commit 28cc5c1.
  • Loading branch information
luv2027 committed Sep 17, 2023
1 parent fbea142 commit 4e73219
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions docs/js/Vault_search.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// const express = require("express");
// const fs = require("fs");
// const path = require("path");
// const app = express();
// const { addListener } = require("process");
// port =3000;

// app.use('/static', express.static('static')) // For serving static files

const firebaseConfig = {
apiKey: "AIzaSyBQBetMo7sP6DV_YvANseKDPb7qSIRCChQ",
Expand Down Expand Up @@ -170,36 +162,3 @@ var plainphone,defphone;
});
}

async function uploadFile() {
const apiKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweDQxNjdDNzNjNzk2OTkxRDVlRWVDQ2ViOThhOUFEMThEYmQ4MGQwNzIiLCJpc3MiOiJ3ZWIzLXN0b3JhZ2UiLCJpYXQiOjE2OTQ5NDA1MTMxNDEsIm5hbWUiOiJFbGVjdHJvdmF1bHQifQ.0gge0hCQfm2KmN40LjubYxu35H56CT5zSpOFtuXNIOc";
const file = fileInput.files[0];

if (!file) {
alert('Please select a file to upload.');
return;
}

const formData = new FormData();
formData.append('file', file);

try {
const response = await fetch('https://api.web3.storage', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
},
body: formData,
});

if (response.ok) {
const { cid } = await response.json();
alert(`File uploaded successfully! CID: ${cid}`);
} else {
alert('File upload failed. Please check your API key and try again.');
}
} catch (error) {
console.error('Error:', error);
alert('An error occurred while uploading the file.');
}
}

0 comments on commit 4e73219

Please sign in to comment.