mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-19 09:34:02 +00:00
| Package | Version | Package | Version | | ---------------------- | ------------ | ---------------------- | ------------ | | @uppy/companion | 5.0.0-beta.6 | @uppy/status-bar | 4.0.0-beta.7 | | @uppy/companion-client | 4.0.0-beta.6 | @uppy/unsplash | 4.0.0-beta.6 | | @uppy/compressor | 2.0.0-beta.7 | @uppy/url | 4.0.0-beta.6 | | @uppy/core | 4.0.0-beta.7 | @uppy/utils | 6.0.0-beta.6 | | @uppy/dashboard | 4.0.0-beta.7 | @uppy/webcam | 4.0.0-beta.6 | | @uppy/dropbox | 4.0.0-beta.6 | @uppy/xhr-upload | 4.0.0-beta.4 | | @uppy/image-editor | 3.0.0-beta.4 | uppy | 4.0.0-beta.7 | | @uppy/screen-capture | 4.0.0-beta.5 | | | - @uppy/companion: switch from `node-redis` to `ioredis` (Dominik Schmidt / #4623) - meta: Fix headings in xhr.mdx (Merlijn Vos) - @uppy/xhr-upload: introduce hooks similar to tus (Merlijn Vos / #5094) - @uppy/core: close->destroy, clearUploadedFiles->clear (Merlijn Vos / #5154) - @uppy/companion-client,@uppy/dropbox,@uppy/screen-capture,@uppy/unsplash,@uppy/url,@uppy/webcam: Use `title` consistently from locales (Merlijn Vos / #5134) | Package | Version | Package | Version | | ------------------ | ------- | ------------------ | ------- | | @uppy/core | 3.11.3 | uppy | 3.25.3 | | @uppy/image-editor | 2.4.6 | | | - @uppy/image-editor: fix tooltips (Avneet Singh Malhotra / #5156) - meta: Remove redundant `plugins` prop from examples (Merlijn Vos / #5145) - @uppy/image-editor: Remove `target` option from examples and document consistently (Merlijn Vos / #5146) - @uppy/core: make getObjectOfFilesPerState more efficient (Merlijn Vos / #5155)
104 lines
3 KiB
HTML
104 lines
3 KiB
HTML
<!doctype html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<title>Uppy</title>
|
||
<link
|
||
href="https://releases.transloadit.com/uppy/v4.0.0-beta.7/uppy.min.css"
|
||
rel="stylesheet"
|
||
/>
|
||
</head>
|
||
<body>
|
||
<section class="example">
|
||
<div id="drag-drop-area"></div>
|
||
<div class="for-ProgressBar"></div>
|
||
<div class="uploaded-files">
|
||
<h5>Uploaded files:</h5>
|
||
<ol></ol>
|
||
</div>
|
||
<script type="module">
|
||
import {
|
||
Uppy,
|
||
DragDrop,
|
||
ProgressBar,
|
||
AwsS3,
|
||
} from 'https://releases.transloadit.com/uppy/v4.0.0-beta.7/uppy.min.mjs'
|
||
|
||
// Function for displaying uploaded files
|
||
const onUploadSuccess = (elForUploadedFiles) => (file, response) => {
|
||
const url = response.uploadURL
|
||
const fileName = file.name
|
||
|
||
const li = document.createElement('li')
|
||
const a = document.createElement('a')
|
||
a.href = url
|
||
a.target = '_blank'
|
||
a.appendChild(document.createTextNode(fileName))
|
||
li.appendChild(a)
|
||
|
||
document.querySelector(elForUploadedFiles).appendChild(li)
|
||
}
|
||
|
||
var uppy = new Uppy({
|
||
autoProceed: true,
|
||
restrictions: {
|
||
maxNumberOfFiles: 10,
|
||
},
|
||
})
|
||
.use(DragDrop, {
|
||
inline: true,
|
||
target: '#drag-drop-area',
|
||
})
|
||
.use(ProgressBar, {
|
||
target: '.example .for-ProgressBar',
|
||
hideAfterFinish: true,
|
||
})
|
||
.use(AwsS3, {
|
||
getUploadParameters(file) {
|
||
// Send a request to our PHP signing endpoint.
|
||
return fetch('/sign-s3', {
|
||
method: 'post',
|
||
// Send and receive JSON.
|
||
headers: {
|
||
accept: 'application/json',
|
||
'content-type': 'application/json',
|
||
},
|
||
body: JSON.stringify({
|
||
filename: file.name,
|
||
contentType: file.type,
|
||
}),
|
||
})
|
||
.then((response) => {
|
||
// Parse the JSON response.
|
||
return response.json()
|
||
})
|
||
.then((data) => {
|
||
// Return an object in the correct shape.
|
||
return {
|
||
method: data.method,
|
||
url: data.url,
|
||
fields: data.fields,
|
||
// Provide content type header required by S3
|
||
headers: {
|
||
'Content-Type': file.type,
|
||
},
|
||
}
|
||
})
|
||
},
|
||
})
|
||
|
||
uppy.on('complete', (result) => {
|
||
console.log(
|
||
'Upload complete! We’ve uploaded these files:',
|
||
result.successful,
|
||
)
|
||
})
|
||
|
||
uppy.on(
|
||
'upload-success',
|
||
onUploadSuccess('.example .uploaded-files ol'),
|
||
)
|
||
</script>
|
||
</section>
|
||
</body>
|
||
</html>
|