mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-23 18:29:09 +00:00
| Package | Version | Package | Version | | ---------------------- | ------- | ---------------------- | ------- | | @uppy/aws-s3 | 3.6.0 | @uppy/instagram | 3.2.0 | | @uppy/aws-s3-multipart | 3.10.0 | @uppy/onedrive | 3.2.0 | | @uppy/box | 2.2.0 | @uppy/provider-views | 3.8.0 | | @uppy/companion | 4.12.0 | @uppy/store-default | 3.2.0 | | @uppy/companion-client | 3.7.0 | @uppy/tus | 3.5.0 | | @uppy/core | 3.8.0 | @uppy/url | 3.5.0 | | @uppy/dropbox | 3.2.0 | @uppy/utils | 5.7.0 | | @uppy/facebook | 3.2.0 | @uppy/xhr-upload | 3.6.0 | | @uppy/google-drive | 3.4.0 | @uppy/zoom | 2.2.0 | | @uppy/image-editor | 2.4.0 | uppy | 3.21.0 | - @uppy/provider-views: fix uploadRemoteFile undefined (Mikael Finstad / #4814) - @uppy/companion: fix double tus uploads (Mikael Finstad / #4816) - @uppy/companion: fix accelerated endpoints for presigned POST (Mikael Finstad / #4817) - @uppy/companion: fix `authProvider` property inconsistency (Mikael Finstad / #4672) - @uppy/companion: send certain onedrive errors to the user (Mikael Finstad / #4671) - meta: fix typo in `lockfile_check.yml` name (Antoine du Hamel) - @uppy/aws-s3: change Companion URL in tests (Antoine du Hamel) - @uppy/set-state: fix types (Antoine du Hamel) - @uppy/companion: Provider user sessions (Mikael Finstad / #4619) - meta: fix `js2ts` script on Node.js 20+ (Merlijn Vos / #4802) - @uppy/companion-client: avoid unnecessary preflight requests (Antoine du Hamel / #4462) - meta: Migrate to AWS-SDK V3 syntax (Artur Paikin / #4810) - @uppy/utils: fix import in test files (Antoine du Hamel / #4806) - @uppy/core: Fix onBeforeFileAdded with Golden Retriever (Merlijn Vos / #4799) - @uppy/image-editor: respect `cropperOptions.initialAspectRatio` (Lucklj521 / #4805)
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/v3.21.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.21.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>
|