Skip to content

DD-2153 Direct upload support#67

Merged
janvanmansum merged 3 commits intoDANS-KNAW:masterfrom
janvanmansum:DD-2153a
Feb 27, 2026
Merged

DD-2153 Direct upload support#67
janvanmansum merged 3 commits intoDANS-KNAW:masterfrom
janvanmansum:DD-2153a

Conversation

@janvanmansum
Copy link
Copy Markdown
Contributor

@janvanmansum janvanmansum commented Feb 27, 2026

Fixes DD-2153

Description of changes

Adds client-side support for Dataverse “S3 Direct Upload” by introducing a response model for upload URL negotiation and new Dataset API methods to request upload URLs and register a prestaged upload.

Notify

@DANS-KNAW/core-systems

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.76%. Comparing base (fdb3b50) to head (d0a2d8b).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...in/java/nl/knaw/dans/lib/dataverse/DatasetApi.java 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #67      +/-   ##
============================================
- Coverage     21.85%   21.76%   -0.10%     
  Complexity       71       71              
============================================
  Files            53       53              
  Lines           961      965       +4     
  Branches         59       59              
============================================
  Hits            210      210              
- Misses          743      747       +4     
  Partials          8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@janvanmansum janvanmansum requested a review from Copilot February 27, 2026 16:33
@janvanmansum janvanmansum marked this pull request as ready for review February 27, 2026 16:33
@janvanmansum janvanmansum requested a review from a team as a code owner February 27, 2026 16:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds client-side support for Dataverse “S3 Direct Upload” by introducing a response model for upload URL negotiation and new Dataset API methods to request upload URLs and register a prestaged upload.

Changes:

  • Add DirectUploadURLs model to represent Dataverse direct-upload URL responses.
  • Extend DatasetApi with getUploadUrls(...) and addFile(PrestagedFile ...) to support direct upload workflows.
  • Update StorageDriver model to include a message field (Dataverse compatibility).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
lib/src/main/java/nl/knaw/dans/lib/dataverse/model/dataset/DirectUploadURLs.java New model for direct upload URL response payload.
lib/src/main/java/nl/knaw/dans/lib/dataverse/model/StorageDriver.java Adds message field; introduces unused import and unclear comment.
lib/src/main/java/nl/knaw/dans/lib/dataverse/DatasetApi.java Adds direct upload endpoints and prestaged-file add method (header consistency issue).
lib/src/main/java/nl/knaw/dans/lib/dataverse/AbstractApi.java Adds unused import.
Comments suppressed due to low confidence (2)

lib/src/main/java/nl/knaw/dans/lib/dataverse/model/StorageDriver.java:25

  • The comment // For older versions of Dataverse (6.7)? is speculative (question mark) and doesn’t explain what behavior/response shape is being handled. Please replace it with a concrete explanation (e.g., what endpoint returns message and in which versions) or remove the comment if it’s not needed.
    // For older versions of Dataverse (6.7)?
    private String message;

lib/src/main/java/nl/knaw/dans/lib/dataverse/DatasetApi.java:537

  • getUploadUrls uses the HttpClientWrapper.get(..., parameters, outputClass) overload which does not send extraHeaders (e.g., X-Dataverse-invocationID). For consistency with other DatasetApi calls and to preserve request correlation, consider using the overload that accepts headers and pass extraHeaders.
    public DataverseHttpResponse<DirectUploadURLs> getUploadUrls(long fileSize) throws IOException, DataverseException {
        return httpClientWrapper.get(subPath("uploadurls"), params(Map.of("size", List.of(String.valueOf(fileSize)))), DirectUploadURLs.class);
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import java.util.Map;

@Data
public class DirectUploadURLs {
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class name DirectUploadURLs doesn’t follow the naming style used elsewhere in this repo (e.g., baseUrl, persistentUrl, DatasetApi use Url/Api rather than all-caps acronyms). Consider renaming to DirectUploadUrls (and file name/imports accordingly) to keep naming consistent.

Suggested change
public class DirectUploadURLs {
public class DirectUploadUrls {

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +29
public class DirectUploadURLs {
private String url;
private Map<String, String> urls;
private long partSize;
private String storageIdentifier;
private String complete;
private String abort;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New response model DirectUploadURLs is added but there’s no corresponding JSON fixture + deserialization/round-trip test like the other model classes in lib/src/test/resources/model/**. Adding a test will help ensure the urls map and optional fields (complete/abort) stay compatible with Dataverse responses.

Copilot uses AI. Check for mistakes.
public DataverseHttpResponse<FileList> addFile(PrestagedFile prestagedFile) throws IOException, DataverseException {
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addPart("jsonData", new StringBody(httpClientWrapper.writeValueAsString(prestagedFile), ContentType.APPLICATION_JSON));
return httpClientWrapper.post(subPath("add"), builder.build(), params(emptyMap()), emptyMap(), FileList.class);
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addFile(PrestagedFile) posts with emptyMap() headers, which drops extraHeaders (notably X-Dataverse-invocationID) that are included in the other addFile(...) overload. This makes behavior inconsistent and may break request tracing/correlation; please pass extraHeaders here as well.

Suggested change
return httpClientWrapper.post(subPath("add"), builder.build(), params(emptyMap()), emptyMap(), FileList.class);
return httpClientWrapper.post(subPath("add"), builder.build(), params(emptyMap()), extraHeaders, FileList.class);

Copilot uses AI. Check for mistakes.
*/
package nl.knaw.dans.lib.dataverse;

import lombok.Getter;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lombok.Getter is imported but not used in this class. Please remove the unused import to avoid warnings or potential build failures when using strict linting/static analysis.

Suggested change
import lombok.Getter;

Copilot uses AI. Check for mistakes.
*/
package nl.knaw.dans.lib.dataverse.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

com.fasterxml.jackson.annotation.JsonIgnore is imported but not used anywhere in this class. Please remove the unused import (or add the missing annotation if it was intended).

Suggested change
import com.fasterxml.jackson.annotation.JsonIgnore;

Copilot uses AI. Check for mistakes.
@janvanmansum janvanmansum merged commit a938258 into DANS-KNAW:master Feb 27, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants