Skip to content

Cannot retrieve any type of identifier from the files created with uploadFile method since it does not return any information of the created file #16

Closed

Description

@AleixMT

When using the uploadFile method, it uses internally the method deposit from class UploadFile. Method deposit returns a DepositReceipt that contains the result of the operation, for example the identifier of the file that you uploaded, but the method uploadFile does not return anything. This makes impossible to keep manipulating the file for example for metadata addition because you are not returning the identification.

¿Could you please explain if this is the intentional design? ¿Is there a possible workaround to obtain the id of the file that you updated with the uploadFile method?

If not I will raise another pull request to fix this or add another method that has this behaviour.

Activity

  1. pdurbin commented on Nov 21, 2022

    @pdurbin
    Member

    The workaround we use in tests is to retrieve the SWORD statement using a method called getFileIdFromSwordStatementBody: https://github.com/IQSS/dataverse/blob/v5.12.1/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java#L1003

    That is to say, from what I can tell, no, with SWORD we don't give you the database ID of the file in the deposit receipt. You have to make a separate call to the get the statement. Yes, this is pretty sub-optimal. The native (JSON) API works in a more sane manner, returning the database ID of the file when you upload the file.

    For reference, this is what I'm seeing as output when you upload a file via SWORD (no "database ID 7" or whatever):

    <entry xmlns="http://www.w3.org/2005/Atom">
      <bibliographicCitation xmlns="http://purl.org/dc/terms/">Lastname, Firstname, 2022, "My Working Title", https://doi.org/10.5072/FK2/E8ZFGV, Root, DRAFT VERSION</bibliographicCitation>
      <generator uri="http://www.swordapp.org/" version="2.0"/>
      <id>http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/edit/study/doi:10.5072/FK2/E8ZFGV</id>
      <link href="http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/edit/study/doi:10.5072/FK2/E8ZFGV" rel="edit"/>
      <link href="http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/edit/study/doi:10.5072/FK2/E8ZFGV" rel="http://purl.org/net/sword/terms/add"/>
      <link href="http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/edit-media/study/doi:10.5072/FK2/E8ZFGV" rel="edit-media"/>
      <link href="http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/statement/study/doi:10.5072/FK2/E8ZFGV" rel="http://purl.org/net/sword/terms/statement" type="application/atom+xml; type=feed"/>
      <treatment xmlns="http://purl.org/net/sword/terms/">no treatment information available</treatment>
      <link href="https://doi.org/10.5072/FK2/E8ZFGV" rel="alternate"/>
    </entry>
    
  2. otter606 commented on Nov 21, 2022

    @otter606
    Contributor

    Hi, I'm working on supporting native API file upload, will do a PR soon. I don't think this was available last time I looked which was a while ago.

  3. pdurbin commented on Nov 22, 2022

    @pdurbin
    Member

    @otter606 fantastic! It's been great watching you and @AleixMT breathe new life into this library! Go go go!

  4. otter606 commented on Nov 26, 2022

    @otter606
    Contributor

    PR #23 contains a fix for this if anyone wants to take a look.

  5. AleixMT commented on Nov 26, 2022

    @AleixMT
    Author

    @pdurbin Thanks for the workaround. Since a PR is incoming I hope that I can use the method the way I needed it :D

    Thank you for your time and work @otter606 , I will take a look to PR #23

  6. richarda23 commented on Feb 28, 2023

    @richarda23
    Collaborator

    closing, assumed done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions