You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The interface Interface DatasetOperations defines the specification for the method void uploadFile(String doi, File file); which as far as my Java knowledge goes (please correct me if there is a workaround for this and I am wrong) it forces the developer to have an instance of File, which has to be on the disk.
In my case, I am retrieving the file data from the database so I do not have a file, instead I have an InputStream / Byte array (preferably an InputStream for memory optimization).
In order to use the method void uploadFile(String doi, File file); from class DatasetOperationsImplV1, I would need to write the InputStream from my DB into disk in order to obtain my File. This is wasteful. (again, correct me if I am wrong).
I checked the implementation of method void uploadFile(String doi, File file); and I noticed that you are using the class FileUploader. From there you are using the SWORD library to perform the update. I can see that you use the class Deposit as a model to send data to the SWORD library for the upload.
The Class Deposit defines the field for the File as private InputStream file = null; (line 8), and its setter (the method that you actually use in class FileUploader to add the file) as public void setFile(InputStream file){...} (line 87). This means that the SWORD library is actually using an InputStream, so adding an overloaded method in your library that receives an InputStream instead of a File should not be very difficult.
Proposed changes:
Class FileUploader implement the overloaded method public DepositReceipt deposit(**InputStream file**, String apiKey, URI dataverseServer, String doi) throws IOException, SWORDClientException, SWORDError, ProtocolViolationException {...}
Class DatasetOperationsImplV1 implement the overloaded method void uploadFile(String doi, ** InputStream file**){...}
Justification of changes:
Optimization and reasonable usage flexibility.
With this I should be able to update a "File" using an InputStream directly from my database without writing to a file temporarily.
Please, tell me what do you think of this proposed changes and also tell me if it makes sense implementing this new way of using your library. If you agree I will try to implement it by myself and when I am finished I will do a pull request.
Any feedback is very much appreciated.
And, again, thanks for this library. It is being very useful for me :D :D
Hi Aleix
Thanks for the detailed proposal. It sounds an excellent idea. You are
right, insisting on a java.util.File is quite restrictive.
Please go ahead and raise a PR.
Thanks again
Richard
Activity
otter606 commentedon Nov 12, 2022
richarda23 commentedon Nov 17, 2022
merged now, thank you