DSPortal is a Python-based utility that simplifies ingesting content into a DSpace 7/8 repository via the REST API. It handles authentication, CSRF protection,
Designed for repeatable and scriptable metadata and file ingestion workflows.
Example methods for item creation, bundle setup, and bitstream uploads.
- Authenticated REST session with CSRF & token handling
- Easy integration with external metadata extraction tools
- Python 3.8+
requests- Access to a DSpace 7/8 instance with REST API enabled
session = DSpaceSession(api_base="https://carleton-dev.scholaris.ca/server/api")
session.authenticate(user="dspace_admin", password="dspace_password")collection_id = "uuid-of-target-collection"
metadata_payload = {
"name": "Title of Work",
"metadata": "Insert structured metadata here",
"inArchive": True,
"discoverable": True,
"withdrawn": False,
"type": "item"
}
item_uuid, item_handle = item_creation(session, collection_id, metadata_payload)og_bundle_id = bundle_creations(session, item_uuid)file = path/to/files
upload_files(session, package_data, og_bundle_id, file, OG_BITSTREAM_PAYLOAD)
- Token Expiration: Sessions expire after ~30 mins. Call
ensure_auth_valid(user, password)to auto-refresh. - CSRF Handling: Automatically managed after login and per request.
- Error Handling: Logs basic failures; expand logging if needed.
- Large Files: Files >1GB are uploaded with
MultipartEncoder(commented out in this sample; plug in your encoder module as needed).
- CLI Wrapper via
click - Retry logic for flaky uploads
- Logging system integration
- Better metadata schema validation before submit