not able to upload a binary file via BDM

vishalrat
vishalrat Member, Employee Posts: 1
Name Dropper
✭✭✭

I am not able to upload a geom file in binary format via BDM

My UI code of "upload file" button:

html.H6("Import Geometery"),
                                    dcc.Upload(
                                        id="upload-data",
                                        children=html.Div([
                                            dcc.Input(id='file-name', type='text', placeholder='No file selected',style={'flex': '1','border': '1px solid #007bff','borderRadius': '999px','padding': '8px 16px'}),
                                            ],style={'display': 'flex','alignItems': 'center','gap': '10px','width': '70%'}
                                            ),
                                        multiple=False,
                                        style={'width': '100%'},
                                    )

Callback for uploading file

@callback(
    Output("file-path-output", "children"),
    Output("file-name", "value"),
    Input("folder-input", "value"),
    Input("upload-data", "contents"),
    State("upload-data", "filename"),
    State("url", "pathname"),
    prevent_initial_call=True,
)
def save_uploaded_file(input_path, contents, filename, pathname):
    project = DashClient[Saf_Template_SimpleSolution].get_project(pathname)
    if contents and filename:
        with project.get_storage_scope() as storage_scope:
            filepath = storage_scope.get_storage_root() / filename
            filepath.write_bytes(contents.split(",")[1].encode("utf-8"))
            print("full_file_path",full_file_path)
            project.steps.geometry_step.my_file_handle = storage_scope.store(filepath)
            return f"File saved to: {filepath}", filename

Answers