mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-28 12:37:00 +00:00
| Package | Version | Package | Version | | ---------------------- | ------- | ---------------------- | ------- | | @uppy/aws-s3-multipart | 3.5.0 | @uppy/locales | 3.2.3 | | @uppy/box | 2.1.2 | @uppy/onedrive | 3.1.2 | | @uppy/companion | 4.7.0 | @uppy/provider-views | 3.4.0 | | @uppy/companion-client | 3.2.1 | @uppy/react | 3.1.3 | | @uppy/core | 3.3.1 | @uppy/status-bar | 3.2.2 | | @uppy/dashboard | 3.4.2 | @uppy/transloadit | 3.2.0 | | @uppy/dropbox | 3.1.2 | @uppy/utils | 5.4.1 | | @uppy/google-drive | 3.2.0 | uppy | 3.12.0 | - @uppy/transloadit: fix error message (Antoine du Hamel / #4572) - @uppy/provider-views: add support for remote file paths (Mikael Finstad / #4537) - @uppy/transloadit: implement Server-sent event API (Antoine du Hamel / #4098) - @uppy/aws-s3-multipart: add support for signing on the client (Antoine du Hamel / #4519) - @uppy/react: allow `id` from props (Merlijn Vos / #4570) - @uppy/aws-s3-multipart: fix lint warning (Antoine du Hamel / #4569) - @uppy/status-bar: listen to `upload` event instead of button click (Antoine du Hamel / #4563) - @uppy/aws-s3-multipart: fix support for non-multipart PUT upload (Antoine du Hamel / #4568) - @uppy/companion: fix esm imports in production/transpiled builds (Dominik Schmidt / #4561) - @uppy/locales: fix expression and spelling errors in es_ES (Rubén / #4567) - meta: upgrade dev dependencies (dependabot\[bot\]) - meta: Don't use triage label (Artur Paikin / #4552) - meta: update Cypress (Antoine du Hamel / #4562) - @uppy/box,@uppy/companion,@uppy/dropbox,@uppy/google-drive,@uppy/onedrive,@uppy/provider-views: Load Google Drive / OneDrive lists 5-10x faster & always load all files (Merlijn Vos / #4513) - @uppy/locales: Add missing pt-BR locales for ImageEditor plugin (Mateus Cruz / #4558)
85 lines
2.7 KiB
HTML
85 lines
2.7 KiB
HTML
<!doctype html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>Uppy</title>
|
||
<link href="https://releases.transloadit.com/uppy/v3.12.0/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/v3.12.0/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>
|