Skip to content

Instantly share code, notes, and snippets.

@mdsohelmia
Created August 8, 2023 13:43
Show Gist options
  • Save mdsohelmia/cc78fae5ac8800f907b03bce95f3932f to your computer and use it in GitHub Desktop.
Save mdsohelmia/cc78fae5ac8800f907b03bce95f3932f to your computer and use it in GitHub Desktop.
Gotipath Stream tus server upload video
<html>
<head>
<link href="https://releases.transloadit.com/uppy/v3.0.1/uppy.min.css" rel="stylesheet" />
</head>
<body>
<div id="drag-drop-area" style="height: 300px"></div>
<div class="for-ProgressBar"></div> <button class="upload-button"
style="font-size: 30px; margin: 20px">Upload</button>
<div class="uploaded-files" style="margin-top: 50px">
<ol></ol>
</div>
<script type="module">
import { Uppy, Tus, DragDrop, ProgressBar, } from 'https://releases.transloadit.com/uppy/v3.0.1/uppy.min.mjs';
const uppy = new Uppy({ debug: true, autoProceed: true });
const onUploadSuccess = el => (file, response) => {
const li = document.createElement('li');
const a = document.createElement('a');
a.href = response.uploadURL; a.target = '_blank';
a.appendChild(document.createTextNode(file.name)); li.appendChild(a);
document.querySelector(el).appendChild(li);
};
uppy
.use(DragDrop, { target: '#drag-drop-area' })
.use(Tus, {
endpoint: 'https://tus-stream.gotipath.com/tusupload/',
retryDelays: [0, 1000, 3000, 5000],
chunkSize: 20 * 1024 * 1024,
headers: {
"VideoId": "61594958-6185-4173-b4dc-7632e2f23ab8", // required
"X-Auth-ClientId": "7d3380de-ee61-45b9-80ba-5fbbf8f87ca8", // required
"X-Auth-LibraryId": "bedeac46-7c0c-4d96-bba1-3f3f1bc43ee2", // required
"X-Auth-ApiKey": "3s7/w9KCeW9UU+TaXvCGAUyGB6NjQwMZw7ghxo56GEizNxe4xHDV+0LME8BWjpDHpt09IQ" // required
},
})
.use(ProgressBar, { target: '.for-ProgressBar', hideAfterFinish: false })
.on('upload-success', onUploadSuccess('.uploaded-files ol'));
const uploadBtn = document.querySelector('button.upload-button'); uploadBtn.addEventListener('click', () => uppy.upload()); </script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment