Prev: Direct upload Next: Web2web Upload API
Split 3D content and meta data¶
In some applications, the 3D content may be provided by a different application or service than the design meta information. This allows the 3D content to be uploaded while the user fills the meta information in a standard Web form.
The 3D content should be POSTed to the following URL:
UPLOAD_URL: https://www.sculpteo.com/{LANGUAGE_CODE}/upload/file/?X-Progress-ID={UUID}
The upload progress and may then be monitored at
FORM_URL: https://www.sculpteo.com/{LANGUAGE_CODE}/upload_design/3D/?X-Progress-ID={UUID}
which also contains a form for filling in the design information, and accepting the terms and conditions of the service.
The UUID value should be set to a unique identifier, for example generated according to RFC4122 (http://tools.ietf.org/html/rfc4122), and should be the same for both UPLOAD_URL and FORM_URL. The following optional GET parameters are available and may be appended to the FORM_URL:
name: specify the default name of the design
unit: the default unit of the design, one of ‘mm’, ‘cm’, ‘m’, ‘in’, ‘ft’, ‘yd’
scale: the default scale of the design, in floating point format
click: where user is redirected after validating the upload form (unset, ‘view’, or ‘cart’)
The unit and scale have the same meaning, default values and behaviour as described in the Direct upload section. Similarly, HTTPS POST to the UPLOAD_URL is supported, and the same extra parameters may be POSTed along the 3D content to set its ownership.
By default, when accessing the FORM_URL, the user is asked to login into Sculpteo to proceed. If you want anonymous users to be able to upload and order designs, the following FORM_URL should be used instead: FORM_URL: https://www.sculpteo.com/{LANGUAGE_CODE}/upload_design/a/3D/?X-Progress-ID={UUID}
Example¶
The following python script uploads a locally generated cube to our platform and opens a window to the upload form:
#!/usr/bin/env python
SCULPTEO_SERVER = "https://www.sculpteo.com"
SCULPTEO_UPLOADFILE = "upload/file"
SCULPTEO_UPLOAD = "upload_design/3D"
import base64
import webbrowser
from uuid import uuid1
import urllib2
def post_design(filename, name, lang="en"):
uuid = uuid1().int
# post the file as base64 encoded content
file_string = base64.urlsafe_b64encode(open(filename, "rb").read())
post_data = "file=%s&filename=%s" % (file_string, filename)
post_url = "%s/%s/%s/?X-Progress-ID=%s" % (
SCULPTEO_SERVER,
lang,
SCULPTEO_UPLOADFILE,
uuid,
)
print(f"POST {post_url} DATA {post_data}")
page = urllib2.urlopen(post_url, post_data)
# redirect to upload page to add name, description, etc...
webbrowser.open_new(
"%s/%s/%s/?X-Progress-ID=%s&name=%s"
% (SCULPTEO_SERVER, lang, SCULPTEO_UPLOAD, uuid, name)
)
def generate_cube(filename):
f = open(filename, "wb")
# vertices
f.write("v 1 -1 -1\n")
f.write("v -1 -1 -1\n")
f.write("v 1 1 1\n")
f.write("v -1 -1 1\n")
f.write("v 1 -1 1\n")
f.write("v -1 1 1\n")
f.write("v 1 1 -1\n")
f.write("v -1 1 -1\n")
# faces
f.write("f 7 1 2\n")
f.write("f 7 2 8\n")
f.write("f 3 6 4\n")
f.write("f 3 4 5\n")
f.write("f 7 3 5\n")
f.write("f 7 5 1\n")
f.write("f 1 5 4\n")
f.write("f 1 4 2\n")
f.write("f 2 4 6\n")
f.write("f 2 6 8\n")
f.write("f 3 7 8\n")
f.write("f 3 8 6\n")
f.close()
def main():
print("generate cube")
generate_cube("example_cube.obj")
print("post it")
post_design("example_cube.obj", "cube")
if __name__ == "__main__":
main()
This sample code for iOS uploads an example zip file and redirects to the mobile checkout pages:
» webapi documentation » Uploading Designs » HTTP POST » Split 3D content and meta data
Last update: 1970-01-01 01:00 (CET)