Well, this is weird. I found an old posting about how to upload files using Python which happens to have been written by @wragge who is the author of the Omeka S Tools Python library. By following his example I have managed to upload a “.glb” file successfully using this code. Note that the final line deliberately gives the MIME type of the file incorrectly as image/jpg which proves that the MIME type declared does not matter at all in terms of determining the file extension to use when saving.
I’m rather surprised. I will have to check the omeka_s_tools code next to see what the differences are!
import requests
import json
omeka_base = 'https://server.host.name.here/omeka-s'
auth = {
'key_identity': 'xxxxxxxxxx',
'key_credential': 'yyyyyyyyyyyy'
}
session = requests.Session()
def attach_media(id, file, type):
media = {
"o:ingester": "upload",
"o:item": {
"@id": f"{omeka_base}/api/items/{id}",
"o:id": id
},
"file_index": "0"
}
files = [
('data', (None, json.dumps(media), 'application/json')),
('file[0]', (file, open(file, 'rb'), type))
]
res = session.post(f"{omeka_base}/api/media", params=auth, files=files)
attach_media(28090, '3DModels/JPEG_example_flower.jpg', 'image/jpg')
attach_media(28090, '3DModels/Wansunt_P1971_6_1_104.glb', 'image/jpeg')
At any rate, it proves it is nothing to do with the ModelViewer module.