Hi,
I try to upload my models with python API v3. So, I would like to set download deny. How to set it in the API script?
The following function I remade was tested but didn’t work.
Please show me the usage.
def upload(path, # this function return 'model_url'
name = 'test model', #'This is a bob model I made with love and passion'
description = 'This is test description. ',
tags = ['research'], #['bob', 'character', 'video-games'], Array of tags
categ = 'science-technology'], # ['people'], Array of categories slugs
license = 'by-nc', #'by', License slug
private = 1, # 1, requires a pro account
password = 'my-password', # requires a pro account
isPublished = False, # Model will be on draft instead of published
isInspectable = True, # Allow 2D view in model inspector
isDownloadAllowed = False,
isDownloadable = False
):
"""
POST a model to sketchfab.
This endpoint only accepts formData as we upload a file.
"""
model_endpoint = f'{SKETCHFAB_API_URL}/models'
# Mandatory parameters
model_file = path # path to your model ex) './data/pikachu.zip'
# Optional parameters
data = {'name': name,
'description': description,
'tags': tags,
'categories': categ,
'license': license,
'private': private,
'password': password,
'isPublished': isPublished,
'isInspectable': isInspectable,
'isDownloadAllowed': isDownloadAllowed,
'isDownloadable': isDownloadable
}
print('Uploading...')
with open(model_file, 'rb') as file_:
files = {'modelFile': file_}
payload = _get_request_payload(data=data, files=files)
try:
response = requests.post(model_endpoint, **payload)
except RequestException as exc:
print(f'An error occured: {exc}')
return
if response.status_code != requests.codes.created:
print(f'Upload failed with error: {response.json()}')
return
# Should be https://api.sketchfab.com/v3/models/XXXX
model_url = response.headers['Location']
print('Upload successful. Your model is being processed.')
print(f'Once the processing is done, the model will be available at: {model_url}')
return model_url