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 {...}
Interface DatasetOperations add the overloaded method void uploadFile(String doi, **InputStream file**);
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
The interface
Interface DatasetOperationsdefines the specification for the methodvoid 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 ofFile, 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/Bytearray (preferably anInputStreamfor memory optimization).In order to use the method
void uploadFile(String doi, File file);from class DatasetOperationsImplV1, I would need to write theInputStreamfrom my DB into disk in order to obtain myFile. 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 classFileUploader. From there you are using the SWORD library to perform the update. I can see that you use the classDepositas a model to send data to the SWORD library for the upload.The
Class Depositdefines the field for theFileasprivate InputStream file = null;(line 8), and its setter (the method that you actually use in classFileUploaderto add the file) aspublic void setFile(InputStream file){...}(line 87). This means that the SWORD library is actually using anInputStream, so adding an overloaded method in your library that receives anInputStreaminstead of aFileshould not be very difficult.Proposed changes:
Class FileUploaderimplement the overloaded methodpublic DepositReceipt deposit(**InputStream file**, String apiKey, URI dataverseServer, String doi) throws IOException, SWORDClientException, SWORDError, ProtocolViolationException {...}Interface DatasetOperationsadd the overloaded methodvoid uploadFile(String doi, **InputStream file**);Class DatasetOperationsImplV1implement the overloaded methodvoid uploadFile(String doi, ** InputStream file**){...}Justification of changes:
With this I should be able to update a "File" using an
InputStreamdirectly 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