Hello there
I’m importing 3D Files to Shapediver. (.stl), in my own custom viewer, using the viewer v3 API:
I seem to have a Problem in my code, which I sadly have been unable to fix thus far. even when using the same code, as the one from the youtube Tutorial:
(https://www.youtube.com/watch?v=hjYaumOhons)
In the File-selection prompt I can at first only select .pdf and .svg files.
I change to all files, select the .stl file, and upload it.
The upload fails with the message:
`
Error Parameter(6db50cc1-ed62-4a9f-b8d1-7659cb412e76).upload: Error uploading FileParameter, type of data () is not a valid type. Has to be application/3dm,application/3ds,application/ai,application/amf,application/dgn,application/dwg,application/dxf,application/fbx,application/iges,application/off,application/pdf,application/ply,application/skp,application/sla,application/slc,application/step,application/vda,application/wavefront-obj,application/x-3ds,application/x-autocad,application/x-dxf,drawing/x-dxf,image/svg+xml,image/vnd.dxf,image/x-3ds,image/x-autocad,image/x-dxf,model/3mf,model/iges,model/obj,model/stl,model/vnd.3dm,x-world/x-3dmf,zz-application/zz-winassoc-dxf.
`
given .stl is not one of the filetypes provided within the Objects.format, I was wondering whether I am using the wrong Fileupload method. However, there only seems to be one function for this (as far as I can tell)
Also the error specifically mentiones .stl as one of the accepted formats.
I doubt that I have a problem within my model, as the upload on the shapediver-Plattform works perfectly.
This is my function which I call for the creation of the upload button:
const createFileParameterElement = (
session: ISessionApi,
paramObject: IParameterApi<File | Blob | string>,
parentDiv: HTMLDivElement
) => {
const paramDiv = createParamDiv(paramObject, parentDiv);
const inputElement = document.createElement("input") as HTMLInputElement;
paramDiv.appendChild(inputElement);
inputElement.type = "file";
inputElement.accept = paramObject.format!.join(','); //
inputElement.onchange = async () => {
if(!inputElement.files || !inputElement.files[0]) return;
paramObject.value = inputElement.files[0];
await session.customize();
};
};
Has anyone an idea whats wrong?
Thanks in advance!