Buckets with objects having different locations

From https://invenio-files-rest.readthedocs.io/en/latest/usage.html I read that:
“Buckets have a default Location and Storage class. Individual objects in the bucket can however have different Locations and Storage classes.”

But I am having a hard time finding in the docs or apis how put a new object in an existing bucket but with the new object having a location different than the other objects. Could someone point me to how to do this either in the API or a REST endpoint?

Thanks for any help!

In the REST API, only the logical objectstore API is exposed, so it’s not possible to control the physical location on disk where to store a file. The code that determines where a file is written to disk is the storage factory (you can change this factory with another, that create files in a different location).

In the programmatic API, you can e.g. link external files like this:

b = Bucket.create(...)
obj = ObjectVersion.create(b, "test.txt")
obj.set_location(uri, size, checksum)
db.session.commit()

See also https://invenio.readthedocs.io/en/latest/tutorials/handling-files.html

1 Like