Bug]: Can't retrieve files having metadata via GET /dns/

Hi I’ve been playing around with the Launcher API and stumbled upon what I think is either a bug or me missing something not entirely obvious around the usage of metadata on files.

The problem: If I set metadata on a file, it can’t be retrieved via
GET /dns/service/longName/filepath
It can¨t be accessed via the proxy either see http://tutorial.drunkcod.safenet/meta.html

The same file without metadata is found and delivered just perfectly.
Also there’s no issues getting the file via the nfs file endpoints.

3 Likes

If the SAFE Network strips out metadata it’s a 1+
I didn’t know, but we all know how govs love metadata :stuck_out_tongue:

I think it’s a bug - ie not implemented yet - as I found it didn’t work with the earlier version of the API either.

If so, this should be noted in the documentation to save developers from wasting time. Sorry I didn’t report it! @Krishna_Kumar

2 Likes

It’s not a bug, it’s a feature :stuck_out_tongue:

1 Like

Metadata, when set, is included when listing files in the directory.
It’s just not possible to actually retrieve a file having metadata set via the dns endpoint.

@drunkcod, the metadata should be a base64 string while creating a file. I tried to debug your problem and the metadata you had set for the file was Here be metadata! which is not a base64 string.

I will file an issue for NFS api not validating metadata to be a valid base64 while creating and updating metadata.

2 Likes

@Krishna_Kumar thanks!

I’m a bit confused though if I do:
GET http://api.safenet/dns/tutorial/drunkcod
part of the response is:

    {
      "name": "meta.html",
      "size": 21,
      "createdOn": "2016-08-14T18:09:28.127Z",
      "modifiedOn": "2016-08-14T18:09:28.129Z",
      "metadata": "SGVyZSBiZSBtZXRhZGF0YSE="
    },

where SGVyZSBiZSBtZXRhZGF0YSE= is indeed the base64 representation of Here be metadata!

That also matches the result from
GET http://api.safenet/nfs/file/app/%2Ftutorial%2Fmeta.html

This is what I expect :slight_smile:

Trying to create a file with a wrongly (non base64) encoded Metadata header yields me
400 Bad Request error code -1507 FfiError::SpecificParseError

So I do think it’s accurately both validating the data and that I did set it in accordance to spec.

Edit: The code I used to create my metadata value, C#
Convert.ToBase64String(Encoding.UTF8.GetBytes(“Here be metadata!”))

2 Likes

I get you, @drunkcod!

Filed an issue in safe_launcher repo. Will get this resolved in the next version.

Thanks!

2 Likes