Hello, I just started learning lakefs, I want to m...
# help
б
Hello, I just started learning lakefs, I want to make my own project on it. I installed the demo and am trying to figure out how to add object metadata when I use the API, but I don't understand how to do it because the upload object method accepts only binary code To summarize, I see that the API has get object metadata, but I don't understand how to add it)
a
Hi @Борис Стук, There is an OpenAPI spec here , and it's really confusing that it doesn't include user metadata. OpenAPI doesn't let us specify it, but it's actually there! See this code from lakectl. In brief, if your upload HTTP POST request includes headers
x-lakefs-meta-xyzzy: foo
then metadata key
xyzzy
will be mapped to
foo
. (Metadata keys are converted to lowercase in this method by HTTP rules.) I hope this helps!
a
Are you looking for an example like this (used in our Spark Demo):
Copy code
obj = branchMain.object(path=fileName)

with open(f"/data/{fileName}", mode='rb') as reader, obj.writer(mode='wb', metadata={'using': 'python_wrapper', 'source':'Spark Demo'}) as writer:
    writer.write(reader.read())
sunglasses lakefs 1