-
Notifications
You must be signed in to change notification settings - Fork 7
Overload method void uploadFile(String doi, File file); to void uploadFile(String doi, InputStream is, String filename); #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2548e9a
62582c8
9d8040f
1f644b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| package com.researchspace.dataverse.api.v1; | ||
|
|
||
| import java.io.File; | ||
| import java.io.InputStream; | ||
| import java.util.List; | ||
|
|
||
| import com.researchspace.dataverse.entities.DataSetMetadataBlock; | ||
|
|
@@ -69,6 +70,15 @@ public interface DatasetOperations { | |
| */ | ||
| void uploadFile(String doi, File file); | ||
|
|
||
| /** | ||
| * Uploads a file using a data stream. | ||
| * | ||
| * @param doi Identifier of the dataset that we are attacking. | ||
| * @param file Stream of data to the contents of the file to upload. | ||
| * @param filename Name of the file. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the input stream doesn't come from a file, but instead from a network or whatever, then the 'file' terminology isn't quite accurate. I think 'filename' is the name you want it to appear as in Dataverse, is that correct? |
||
| */ | ||
| void uploadFile(String doi, InputStream file, String filename); | ||
|
otter606 marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * Deletes a {@link Dataset} | ||
| * @param dsIdentifier | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.net.URI; | ||
| import java.net.URISyntaxException; | ||
| import java.util.List; | ||
|
|
@@ -224,6 +225,23 @@ public void uploadFile (String doi, File file) { | |
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void uploadFile(String doi, InputStream file, String filename) { | ||
| FileUploader uploader = new FileUploader(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could uploadFile(string, file) call in order to reduce duplication? |
||
| try { | ||
| uploader.deposit(file, filename, apiKey, new URI(serverURL), doi); | ||
| } catch (IOException | SWORDClientException | ProtocolViolationException | URISyntaxException e) { | ||
| log.error("Couldn't upload file {} with doi {} : {}", filename, doi.toString(), e.getMessage()); | ||
| throw new RestClientException(e.getMessage()); | ||
| } catch (SWORDError error) { | ||
| if (!StringUtils.isEmpty(error.getErrorBody())) { | ||
| log.error("SwordError: {}", error.getErrorBody()); | ||
| throw new RestClientException(error.getErrorBody()); | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| /* (non-Javadoc) | ||
| * @see com.researchspace.dataverse.http.DataverseAPI#deleteDataset(com.researchspace.dataverse.entities.Identifier) | ||
| */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.