index.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Uppy – AWS upload example</title>
  6. <link href="./uppy.min.css" rel="stylesheet" />
  7. </head>
  8. <body>
  9. <h1>AWS upload example</h1>
  10. <details open name="uppy">
  11. <summary>Sign on the server</summary>
  12. <div id="uppy-sign-on-server"></div>
  13. </details>
  14. <details name="uppy">
  15. <summary>Sign on the client (if WebCrypto is available)</summary>
  16. <div id="uppy-sign-on-client"></div>
  17. </details>
  18. <footer>
  19. You seeing the simplified example, with a backend that mimicks a
  20. Companion-like instance. See
  21. <a href="./withCustomEndpoints.html">the custom endpoint example</a> if
  22. you need to see how to use one or more custom function for handling
  23. communication with the backend.
  24. </footer>
  25. <noscript>You need JavaScript to run this example.</noscript>
  26. <script type="module">
  27. import { Uppy, Dashboard, AwsS3 } from './uppy.min.mjs'
  28. function onUploadComplete(result) {
  29. console.log(
  30. 'Upload complete! We’ve uploaded these files:',
  31. result.successful,
  32. )
  33. }
  34. function onUploadSuccess(file, data) {
  35. console.log(
  36. 'Upload success! We’ve uploaded this file:',
  37. file.meta['name'],
  38. )
  39. }
  40. {
  41. const uppy = new Uppy()
  42. .use(Dashboard, {
  43. inline: true,
  44. target: '#uppy-sign-on-server',
  45. })
  46. .use(AwsS3, {
  47. id: 'myAWSPlugin',
  48. endpoint: '/',
  49. })
  50. uppy.on('complete', onUploadComplete)
  51. uppy.on('upload-success', onUploadSuccess)
  52. }
  53. {
  54. const uppy = new Uppy()
  55. .use(Dashboard, {
  56. inline: true,
  57. target: '#uppy-sign-on-client',
  58. })
  59. .use(AwsS3, {
  60. id: 'myAWSPlugin',
  61. endpoint: '/',
  62. getTemporarySecurityCredentials: typeof crypto?.subtle === 'object',
  63. })
  64. uppy.on('complete', onUploadComplete)
  65. uppy.on('upload-success', onUploadSuccess)
  66. }
  67. </script>
  68. </body>
  69. </html>