Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,49 @@ A web tool for uploading folders of files to a Dataverse dataset. See [the wiki]
The Hosted version at https://gdcc.github.io/dvwebloader can be used for testing. You should fork or install a local copy for production use (to avoid changes made in this repository immediately being available from your Dataverse installation.)
You may also want to run the localinstall.sh script in the directory you download to to make and local copies of the libraries used.

## DVWebloader Versions

### V1 (Original)
- **File**: `src/dvwebloader.html`
- **Technology**: Vanilla JavaScript with jQuery
- Lightweight and well-tested

### V2 (Experimental)

> ⚠️ **Prototype / Experimental**: V2 is currently a prototype for testing purposes. It may have bugs or missing features. Use V1 for production workloads.

- **File**: `src/dvwebloaderV2.html`
- **Technology**: React 18, TypeScript (pre-built bundle)

V2 reuses the file upload components from the new Dataverse SPA ([dataverse-frontend](https://github.com/IQSS/dataverse-frontend)) and the official JavaScript client library ([dataverse-client-javascript](https://github.com/IQSS/dataverse-client-javascript)). This ensures consistency with the main Dataverse application and reduces code duplication.

The bundle is built from `dataverse-frontend/src/standalone-uploader/` and packaged as a standalone JavaScript file that can run independently of the SPA.

#### V2 Configuration

Configuration is set via `window.dvWebloaderConfig` in the HTML file before the bundle loads:

```html
<script>
window.dvWebloaderConfig = {
useS3Tagging: true, // Set to false for S3-compatible storage (e.g., MinIO)
maxRetries: 3, // Retry multipart uploads up to N times
uploadTimeoutMs: 0, // Timeout in ms (0 = unlimited)
disableMD5Checksum: false // Set to true to skip checksum calculation
};
</script>
<script type="module" src="lib/dvwebloader-v2.js"></script>
```

| Option | Default | Description |
|--------|---------|-------------|
| `useS3Tagging` | `true` | Set to `false` to disable S3 tagging (for S3-compatible storage) |
| `maxRetries` | `3` | Maximum retries for multipart upload parts |
| `uploadTimeoutMs` | `0` | Upload timeout in ms (`0` = unlimited) |
| `disableMD5Checksum` | `false` | Set to `true` to skip checksum calculation |

## Integration

### Current integration mechanism (v5.13+):

Configure dvwebloader as an integrated [UploadMethod](https://guides.dataverse.org/en/latest/installation/config.html#uploadmethods):
Expand Down
88 changes: 88 additions & 0 deletions src/dvwebloaderV2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dataverse WebLoader V2</title>
<!-- Configuration: set before the bundle loads -->
<script>
window.dvWebloaderConfig = {
useS3Tagging: false, // Disable S3 tagging (for MinIO/S3-compatible storage)
maxRetries: 3, // Retry multipart uploads up to 3 times
uploadTimeoutMs: 0, // No timeout (0 = unlimited)
disableMD5Checksum: false // Calculate MD5 checksums
};
</script>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f8f9fa;
}
.page-container {
max-width: 1200px;
margin: 0 auto;
}
.page-header h1 {
margin: 0 0 10px 0;
font-size: 1.75rem;
font-weight: 500;
}
.dataset-info {
margin: 0 0 15px 0;
font-size: 0.9rem;
}
.dataset-info code {
color: #d63384;
background: #f8f9fa;
padding: 2px 6px;
border-radius: 4px;
}
.helper-text {
font-size: 0.85rem;
color: #6c757d;
margin-bottom: 15px;
}
.helper-text a {
color: #0d6efd;
}
.footer {
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid #dee2e6;
text-align: center;
font-size: 0.85rem;
color: #6c757d;
}
.footer a {
color: #0d6efd;
}
</style>
<!-- The bundle includes all CSS inlined via vite-plugin-css-injected-by-js -->
<script type="module" src="dvwebloader-v2.js"></script>
</head>
<body>
<div class="page-container">
<header class="page-header">
<h1>Upload Files</h1>
<p class="dataset-info">Uploading to dataset: <code id="dataset-pid"></code></p>
</header>

<!-- React uploader mounts here -->
<div id="root"></div>

<footer class="footer">
<a href="https://github.com/gdcc/dvwebloader" target="_blank" rel="noreferrer">DVWebloader V2</a>
<span> - Powered by Dataverse Frontend</span>
</footer>
</div>

<script>
// Extract datasetPid from URL and display it
const urlParams = new URLSearchParams(window.location.search);
const datasetPid = urlParams.get('datasetPid') || 'Unknown';
document.getElementById('dataset-pid').textContent = datasetPid;
</script>
</body>
</html>
50 changes: 50 additions & 0 deletions src/embeddedDvWebloader.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload Files</title>
<!-- DVWebloader V2 Embedded Mode - for use in iframe within Dataverse JSF pages -->
<!-- Configuration: useS3Tagging comes from URL param (from Dataverse JVM setting) -->
<script>
window.dvWebloaderConfig = {
maxRetries: 3,
uploadTimeoutMs: 300000,
disableMD5Checksum: false
};
</script>
<style>
html, body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background-color: transparent;
}
#root {
padding: 10px;
}
</style>
<script type="module" src="dvwebloader-v2.js"></script>
<script>
// Send height to parent for dynamic iframe sizing
function sendHeightToParent() {
const height = document.documentElement.scrollHeight;
window.parent.postMessage({ type: 'dvwebloader-resize', height: height }, '*');
}

// Observe DOM changes to detect when content size changes
const resizeObserver = new ResizeObserver(sendHeightToParent);

document.addEventListener('DOMContentLoaded', function() {
resizeObserver.observe(document.body);
sendHeightToParent();
});

// Also send on window resize
window.addEventListener('resize', sendHeightToParent);
</script>
</head>
<body>
<div id="root"></div>
</body>
</html>
335 changes: 335 additions & 0 deletions src/lib/dvwebloader-v2.js

Large diffs are not rendered by default.

Loading