Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

 

Friendly URLs

 

Sometimes it is hard for a client to get the global identifier of a record, generated version name of a representation and generated filename. On the other hand the client has got a local record identifier which is well known. The same may be in case of a filename. In order to access files without retrieving the hard to remember identifiers and names mechanism of friendly URLs was introduced. The idea behind it is to use in URLs well known values (identifiers, names, etc.) always in the same way. Here we will go through the tutorial steps using friendly URLs where it is possible.

 

Record

 

Normally when you know the cloud identifier of a record you can access it using URL like this:

 

Code Block
https://cloud.europeana.eu/api/records/X67WPA7NGCZUKLACPWU3BORRGQUWTKSZNZDICEGZS6IXTRMINOIQ

 

If you remember from the beginning of this tutorial, this record was created for PSNC data provider together with local identifier which was exampleLocalRecord. So now we have only two values: name of the data provider (PSNC) and identifier used by this data provider (exampleLocalRecord). To get access to this record in Europeana Cloud using just these two values we can use friendly URL like this:

 

Code Block
curl -X GET -H "Accept: application/json" --user user:password -i https://cloud.europeana.eu/api/data-providers/PSNC/records/exampleLocalRecord

 

Representation

 

Sometimes it is necessary to get access to a specific representation. Again, instead of retrieving the global identifier we can use well known values like data provider name, local record identifier and representation name. Let's display information about the TIFFrepresentation using the friendly URL:

 

Code Block
curl -X GET -H "Accept: application/json" --user user:password -i https://cloud.europeana.eu/api/data-providers/PSNC/records/exampleLocalRecord/representations/TIFF

 

File

 

If you do not want to have files with names generated by the system there is possibility to specify the name in the insert request. We can add a file to TIFF representation and specify a name for it like this:

 

Code Block
curl -X POST --user user:password -H "Content-Type: multipart/form-data" -F "mimeType=image/tiff" -F "data=@tiff.tiff" -F "fileName=abc" https://cloud.europeana.eu/api/records/X67WPA7NGCZUKLACPWU3BORRGQUWTKSZNZDICEGZS6IXTRMINOIQ/representations/TIFF/versions/27ae2a60-3ebf-11e6-b03d-fa163e8d4ae3/files

 

As you can see the specified filename is abc. Now we can use it to access this file in Europeana Cloud via friendly URL.

 

Note

Just remember that a file will not be accessible until you make its representation persistent.

Code Block
 curl -X GET -H "Accept: application/json" --user user:password -i https://cloud.europeana.eu/api/data-providers/PSNC/records/exampleLocalRecord/representations/TIFF/abc

 

Filename used instead of a generated one can be also much more complex. It can for example contain / characters like in the absolute path. We can take a look at the real example provided by Europeana Newspapers.

Code Block
https://cloud.europeana.eu/api/data-providers/TheEuropeanLibrary/records/3000100349685/representations/presentation_images/node-2/image/NLE/???????????_??????????_?????????_=_Livländische_Gouvernements-Zeitung/1862/01/03/18620103_1-0001.jp2

 

As you can see the filename used here (node-2/image/NLE/???????????_??????????_?????????_=_Livländische_Gouvernements-Zeitung/1862/01/03/18620103_1-0001.jp2) is not only long with / characters but also contains unicode characters. We can also extract other well known values from this URL: data provider - TheEuropeanLibrary, local record identifier - 3000100349685, representation name - presentation_images.

 

 

Future Work and Contact

Europeana Cloud is now in its alpha phase. During the remainder of the project we’ll improve the platform and the API based on the feedback from the community.

We welcome your feedback. Please write to pavel.kats at europeana.eu.