Browse local file - websocket (in a custom page)

Hi,

I’m creating a web app (python/flask) to inject data into SG, and now I need to add a custom file field. I basically want to mimc the “Browse…” button from file fields (“link to local” mode) in a custom html page. Already installed Shotgun desktop app, websocket running ok on port 9000. Question is, how do I connect to this server and how to launch the file chooser dialog ? What should be in the html for it to work ? I’ve searched a lot before posting this, but looks like there are no examples online. sorry if this sounds like a newbie question.

thanks

Hi @fabricio.chamon,

Welcome to the community and thanks for posting your question here. Sorry I do not have an answer to your question here, but just want to let you know that most of the team are out for holidays and it might take us longer to get back to you here.

Thanks for bearing with us and wish you a Happy New Year.

Cheers,
Ben

1 Like

no worries. thanks Ben!

Hi @fabricio.chamon,

I want to clear the question. You want to access local folder or file from your html page from web app?

Did you try <input type="file" name="datafile" size="40" multiple> in your html page?

Thanks

Loney

1 Like

Hi Loney,

The regular file input does not suffice as it won’t return the complete file path due to browser security reasons.
As I understand it, shotgun alternative for this is to use the shotgun desktop app own websocket server to launch a custom file chooser when user clicks the “Browse…” button (for local files) in the shotgun web app interface.

I want to mimic that, but inside my own web app. I don’t know how to call this server to open the file chooser and get the selected file fullpath from that.

Hi @fabricio.chamon,

Tanks for clarifying the question. As I know, we don’t expose this yet. It is only for shotgun web to communicate with desktop.

I will leave it here to wait other experts input after they come back from holiday.

Thanks

Loney

1 Like

Allright, thanks Loney!

To be more specific, I’m talking about this: https://support.shotgunsoftware.com/hc/en-us/articles/219030858

Hi @fabricio.chamon

I think there are a few things to say here.

As you mention, when you have Shotgun Desktop installed and running, the Shotgun web app allows you to browse to files on disk. You can’t, however, access this server directly and issue commands to it. The Desktop browser integration is there to be used with Toolkit. You can create custom Toolkit apps that will be displayed as actions that can be launched via the web app, and run python code locally on the machine. If you’re not already using Toolkit/Pipeline Integrations then this may not be the approach you want to use.

Alternatively, you can set up your own AMI where the requests are handled by your own server which doesn’t depend on Shotgun Desktop and Toolkit at all.

In both cases, you can’t reuse the file picker dialog shown in the Shotgun web app, you would need to create your own file picker. If you are doing it as a Toolkit app, or a python/flask server then you could use the QT File Dialog to do this perhaps?

Best
Phil

Hi Philip,

ok great, thanks for the clarification!

1 Like