Show attachment URLs in queries and when data exporting

This guide walks through how to configure Specify so that you can export Collection Object Attachment URLs from your Specify Attachment/Asset Server that can link to your images when sharing data internally or with data aggregators. These instructions can be adapted to work with any table’s attachments.

:warning: You must have the Specify Asset Server configured and publically accessible. To see if this is the case, try to view several Specify attachments in your web browser.


Specify 7 Instructions

  1. In App Resources, go to the DataObjFormatters resource. This is most likely under your discipline. See an example.

In the format section, add the following XML snippet:

    <format
        name="CollectionObjectAttachment"
        title="CollectionObjectAttachment"
        class="edu.ku.brc.specify.datamodel.CollectionObjectAttachment"
        default="true"
        >
        <switch single="true">
            <fields>
                <field sep="http://biimages.biodiversity.ku.edu/static/Ichthyology/originals/">attachment.attachmentLocation</field>
            </fields>
        </switch>
    </format>
  1. Replace http://biimages.biodiversity.ku.edu/static/Ichthyology/originals/ in the above XML snippet with the base URL for your attachments.

:bulb: For example, here is another URL for an attachment:

https://demo-assets.specifycloud.org/fileget?coll=sp7demofish&type=O&filename=sp62280762705929643056.att.JPG&downloadname=DDB13-16b.JPG

I can safely remove everything following the filename= as that is where the AttachmentLocation information is located.

I would replace

http://biimages.biodiversity.ku.edu/static/Ichthyology/originals/

with

https://demo-assets.specifycloud.org/fileget?coll=sp7demofish&amp;type=O&amp;filename=`

:warning: Note: Replace ampersands (&) with its XML equivalent, &amp;.


As you may have known, the AttachmentLocation field contains the actual name given to the attachment by Specify when it is added to the asset server:

By establishing this format, we are making it so that this is added to the end of the attachment base URL so that the images can be linked to from external sources (GBIF, iDigBio, etc.).

  1. In the aggregator section, add the following XML snippet:
    <aggregator name="CollectionObjectAttachment"
                title="CollectionObjectAttachment"
                class="edu.ku.brc.specify.datamodel.CollectionObjectAttachment"
                default="true"
                separator=" | "
                ending=""
                count="0"
                format="CollectionObjectAttachment"
                orderfieldname="ordinal"
               />
  1. In the Schema Config tool, navigate to the CollectionObjectAttachment table:

    ex. https://sp7demofish.specifycloud.org/specify/schema-config/en/CollectionObjectAttachment/

    Once there, choose both the CollectionObjectAttachment aggregation and format.

  1. Click Save in the top right of the schema config window, clear your cache, then run a query! You should now see the format and aggregation in action!

Specify 6 Instructions

  1. Go to SystemSchema Configuration…

  2. Select the locale of your choice and click Edit a Schema.

  3. Go to attachment in the Tables list, then make sure you have unhidden AttachmentLocation by unchecking the “Hide Field” check box.

  4. If it was hidden, click OK and repeat steps 1-2 to return to the Schema Configuration tool. If it was already unhidden, proceed.

  5. Go to collectionobjectattachment in the Tables list, then click on the button next to the Table Fomat pick list.

  6. Click on the :plus_: button in the bottom right of the dialog.

  7. Create a new table format that has the beginning of your attachment URL before the AttachmentLocation field. Make sure to give it a name and a title.

    You can find the base URL for your attachments by going directly to an attachment in your web browser and copying the URL.

    As you may have known, the AttachmentLocation field contains the actual name given to the attachment by Specify when it is added to the asset server:

    By establishing this format, we are making it so that this is added to the end of the attachment base URL so that the images can be linked to from external sources (GBIF, iDigBio, etc.).

    For example, here is a URL for an attachment:

    http://biimages.biodiversity.ku.edu/static/Ichthyology/originals/sp64880800553830292016.att.JPG
    

    You can see that the URL can be constructed in Specify by adding the AttachmentLocation value to the end of the static portion.

  8. Still under collectionobjectattachment in the Tables list, click on the button next to the Table Aggregation pick list.

  1. Click on the :plus_: button in the bottom right of the dialog.

  2. Create a new table aggregation by selecting your newly created format as the Display and then adding a separator of your choosing. Make sure to give it a name and a title.

  3. Finally, choose both the newly created format and aggregation for the collectionobjectattachment table! Click OK to save your changes.


Now when you run a query, you can see the the results showing with the URL you configured! Even better, mutliple URLs will be aggregated in one field with the separator of your choosing so that you can export a link to all attachments associated with your Collection Objects!