Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
abhu89 authored Nov 7, 2024
1 parent c1c8847 commit 7698521
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Protected File Access</title>
<style>
body { font-family: Arial, sans-serif; }
#fileLink { display: none; }
</style>
<title>Access File</title>
</head>
<body>
<h2>Enter Password to Access the File</h2>
<input type="password" id="passwordInput" placeholder="Enter Password">
<button onclick="checkPassword()">Submit</button>

<div id="fileLink">
<p>Access your file here: <a href="SIGNED_URL" target="_blank">Download File</a></p>
<input type="password" id="password" placeholder="Enter Password">
<button onclick="accessFile()">Submit</button>
<div id="linkContainer" style="display:none;">
<p>Access your file here: <a id="fileLink" href="#" target="_blank">Download File</a></p>
</div>

<script>
function checkPassword() {
const password = "PASSWORD"; // Set your password here
const userInput = document.getElementById("passwordInput").value;

if (userInput === password) {
document.getElementById("fileLink").style.display = "block";
async function accessFile() {
const password = document.getElementById("password").value;
const response = await fetch("https://us-central1-mersive-techops-project.cloudfunctions.net/generateSignedUrl?bucketName=mersive-yocto-dev&fileName=_20241002_032753.tar.gz", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ password })
});

const data = await response.json();

if (data.success) {
document.getElementById("fileLink").href = data.signedUrl;
document.getElementById("linkContainer").style.display = "block";
} else {
alert("Incorrect password. Please try again.");
}
Expand Down

0 comments on commit 7698521

Please sign in to comment.