menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

Theia

Eclipse Theia - Cloud & Desktop IDE

Channels
Team

Serving binary files from workspace, referenced by other files in the workspace

August 11, 2019 at 8:03am

Serving binary files from workspace, referenced by other files in the workspace

August 11, 2019 at 8:03am
I have some binary 3d models that I would like to put into the workspace and allow the user to reference those files via uri from separate json files, also in the workspace - the uri is handed to another library for processing, so I don't have any control over how it loads the models other than the uri.
In a stock express program, I would just serve up the static assets like app.use(express.static('public')). How would I go about doing this within the theia framework?

August 12, 2019 at 8:11am
Do you think it would be possible to achieve with download links?
You can implement configure lifecycle callback of the backend contribution which receives the backend application that exposes use method.
oh great idea, thanks. Another possibility I was thinking was to create a backend service that spins up a separate server just for serving up assets in the workspace - like in gitpod where you can run another instance of theia and it exposes the port - I wonder how that works though and if it is an extension or a gitpod proprietary thing
i get cors policy errors if I try this in a basic way
You are better to ask Gitpod related questions in Gitpod community: https://spectrum.chat/gitpod I'm not very familiar with internals of Gitpod.
I think though that you will need a proxy which server both Theia and file server from the same origin to avoid cors issues. Or you can configure Theia that accepts requests from another origin as well.