Skip to content

Instantly share code, notes, and snippets.

@csjx
Created September 9, 2020 21:34
Show Gist options
  • Save csjx/74452a33c32f14a03662d2e295cfaaed to your computer and use it in GitHub Desktop.
Save csjx/74452a33c32f14a03662d2e295cfaaed to your computer and use it in GitHub Desktop.

Set my token

export token="<token-goes-here>"

Create a 200MB file:

dd if=/dev/urandom of=200MB-file.txt bs=1M count=200

Write the system metadata file to cjones.10000.1.sysmeta.xml with:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns3:systemMetadata xmlns:ns2="http://ns.dataone.org/service/types/v1" xmlns:ns3="http://ns.dataone.org/service/types/v2.0">
    <serialVersion>1</serialVersion>
    <identifier>cjones.10000.1</identifier>
    <formatId>text/plain</formatId>
    <size>209715200</size>
    <checksum algorithm="MD5">9125b60f354f9d74311ddda715f237bb</checksum>
    <submitter>http://orcid.org/0000-0002-8121-2341</submitter>
    <rightsHolder>http://orcid.org/0000-0002-8121-2341</rightsHolder>
    <fileName>200MB-file.txt</fileName>
</ns3:systemMetadata>

Upload the file

time curl \
    -X POST \
    -H "Authorization: Bearer ${token}" \
    -F "pid=cjones.10000.1" \
    -F "sysmeta=@cjones.10000.1.sysmeta.xml" \
    -F "object=@200MB-file.txt" \
    "https://test.arcticdata.io/metacat/d1/mn/v2/object"

Note that the sysmeta is encoded before the object in the curl call

Results

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<identifier xmlns="http://ns.dataone.org/service/types/v1">cjones.10000.1</identifier>

real	0m5.410s
user	0m0.238s
sys	0m0.196s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment