Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zip files and generate link #1

Merged
merged 2 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
env/
Binary file modified clickShare/clickShare/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file modified clickShare/clickShare/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file modified clickShare/clickShare/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file modified clickShare/clickShare/__pycache__/wsgi.cpython-310.pyc
Binary file not shown.
Binary file modified clickShare/db.sqlite3
Binary file not shown.
Binary file modified clickShare/home/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file modified clickShare/home/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file modified clickShare/home/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file modified clickShare/home/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file modified clickShare/home/__pycache__/serializers.cpython-310.pyc
Binary file not shown.
Binary file modified clickShare/home/__pycache__/views.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified clickShare/home/migrations/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion clickShare/home/serializers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shutil
import shutil
from numpy import require
from rest_framework import serializers
from .models import *
Expand Down
134 changes: 134 additions & 0 deletions clickShare/home/templates/download.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> -->

<style>
/**
* FilePond Custom Styles
*/
.filepond--drop-label {
color: #4c4e53;
}

.filepond--label-action {
-webkit-text-decoration-color: #babdc0;
text-decoration-color: #babdc0;
}

.filepond--panel-root {
border-radius: 2em;
background-color: #edf0f4;
height: 1em;
}

.filepond--item-panel {
background-color: #595e68;
}

.filepond--drip-blob {
background-color: #7f8a9a;
}

/**
* Page Styles
*/
html {
padding: 3vh 0 0;
}

body {
max-width: 28em;
margin: 0 auto;
background-color: #03a9f4;
}
.background {

border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
}
.clipboard {
border: 0;
padding: 15px;
border-radius: 3px;
background-image: linear-gradient(135deg, #FDEB71 10%, #F8D800 100%);
cursor: pointer;
color: #04048c;
font-family: "Karla", sans-serif;
font-size: 16px;
position: relative;
top: 0;
transition: all 0.2s ease;
}
body .clipboard:hover {
top: 2px;
}
body p {
font-weight: 700;
}
</style>
</head>

<body>
<link href="https://unpkg.com/filepond/dist/filepond.css" rel="stylesheet">
<link href="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css" rel="stylesheet">

<script src="https://cdnjs.cloudflare.com/ajax/libs/filepond/4.30.3/filepond.min.js"
integrity="sha512-AuMJiyTn/5k+gog21BWPrcoAC+CgOoobePSRqwsOyCSPo3Zj64eHyOsqDev8Yn9H45WUJmzbe9RaLTdFKkO0KQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script src="https://unpkg.com/jquery-filepond/filepond.jquery.js"></script>
<script src="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.js"></script>


<div class="text-center">

<img src="/media/image/download.svg" class="img-fluid img-responsive" style="height: 200px;">
</div>


<div class="carad mt-5" >
<div class="card-bodqy">


<div class="background">
<center>
<a href="/media/zip/{{uid}}.zip" class="clipboard">Download Files</a>
<p>Have you already clicked?</p>
</center>
</div>

</div>
</div>
</div>


<script src="https://unpkg.com/filepond/dist/filepond.min.js"></script>





<script>
$(function () {
$.fn.filepond.registerPlugin(FilePondPluginImagePreview, );
$('.my-pond').filepond();
$('.my-pond').filepond('allowMultiple', true);
$('.my-pond').on('FilePond:addfile', function (e) {
console.log('file added event', e);
});
});
</script>

</body>

</html>
175 changes: 174 additions & 1 deletion clickShare/home/templates/home.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,185 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> -->

<style>
/**
* FilePond Custom Styles
*/
.filepond--drop-label {
color: #4c4e53;
}

.filepond--label-action {
-webkit-text-decoration-color: #babdc0;
text-decoration-color: #babdc0;
}

.filepond--panel-root {
border-radius: 2em;
background-color: #edf0f4;
height: 1em;
}

.filepond--item-panel {
background-color: #595e68;
}

.filepond--drip-blob {
background-color: #7f8a9a;
}

/**
* Page Styles
*/
html {
padding: 3vh 0 0;
}

body {
max-width: 28em;
margin: 0 auto;
background-color: #03a9f4;
}

.background {

border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
}

.clipboard {
border: 0;
padding: 15px;
border-radius: 3px;
background-image: linear-gradient(135deg, #FDEB71 10%, #F8D800 100%);
cursor: pointer;
color: #04048c;
font-family: "Karla", sans-serif;
font-size: 16px;
position: relative;
top: 0;
transition: all 0.2s ease;
}

body .clipboard:hover {
top: 2px;
}

body p {
font-weight: 700;
}
</style>
</head>

<body>
UI will be Rendered Here.
<link href="https://unpkg.com/filepond/dist/filepond.css" rel="stylesheet">
<link href="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css"
rel="stylesheet">

<script src="https://cdnjs.cloudflare.com/ajax/libs/filepond/4.30.3/filepond.min.js"
integrity="sha512-AuMJiyTn/5k+gog21BWPrcoAC+CgOoobePSRqwsOyCSPo3Zj64eHyOsqDev8Yn9H45WUJmzbe9RaLTdFKkO0KQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script src="https://unpkg.com/jquery-filepond/filepond.jquery.js"></script>
<script src="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.js"></script>


<div class="text-center">

<img src="/media/image/undraw.svg" class="img-fluid img-responsive" style="height: 200px;">
</div>

<input type="file" class="my-pond mt-4" multiple name="filepond" />

<div class="text-center">
<button class="btn btn-success" onclick="upload_file()">Upload File</button>
</div>

<div class="carad mt-3" id="btn" style="display: none;">
<div class="card-bodqy">


<div class="background">
<center>
<button onclick="copyClip()" class="clipboard">Click me to copy current Url</button>
<p>Have you already clicked?</p>
</center>
</div>

</div>
</div>
</div>


<script src="https://unpkg.com/filepond/dist/filepond.min.js"></script>





<script>
FilePond.registerPlugin(
FilePondPluginImagePreview,

);

const pond = FilePond.create(
document.querySelector('.my-pond')
);

var url = null

function upload_file() {
var files = pond.getFiles()

var formdata = new FormData()

for (var i = 0; i < files.length; i++) {
formdata.append('files', files[i].file)
}

fetch('/handle/', {
method: 'POST',
headers: {
'X-CSRFToken': "{{csrf_token}}"
},
body: formdata
}).then(res => res.json())
.then(result => {
console.log(result)

url = `http://127.0.0.1:8000/download/${result.data.folder}`

document.getElementById('btn').style.display = '';df -h


})

}

function copyClip() {
console.log('dd')


/* Copy the text inside the text field */
navigator.clipboard.writeText(url);

/* Alert the copied text */
alert("Copied the text: " + url);
}
</script>

</body>

</html>
5 changes: 0 additions & 5 deletions clickShare/home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ def home(request):
return render(request,'home.html')







class Handle_Uploaded_Files(APIView):
parser_classes = [MultiPartParser]
def post(self , request):
Expand Down
Loading