Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a feature in FreeCC to pass a file from container to the host #29

Closed
ouankou opened this issue Jul 31, 2020 · 1 comment
Closed
Assignees

Comments

@ouankou
Copy link
Owner

ouankou commented Jul 31, 2020

To be safe, the file should be passed to /tmp and never be executed.
Then the file can be downloaded from frontend by user.

@ouankou ouankou self-assigned this Jul 31, 2020
@ouankou ouankou added this to To do in FreeCompilerCamp Jul 31, 2020
@ouankou
Copy link
Owner Author

ouankou commented Aug 3, 2020

PWD has a handler to get a file from the container. We don't need to implement a new function.
https://github.com/freeCompilerCamp/play-with-compiler/blob/a8e345233629088d3a618c531a5436a2dabfb3b3/handlers/bootstrap.go#L82

The definition is located in: https://github.com/freeCompilerCamp/play-with-compiler/blob/master/handlers/file_instance.go

To use this function, assume we open a tutorial and create test.txt in the home folder /home/freecc. For any sandbox, a session id and a instance id will be generated automatically. The following GET request will get /home/freecc/test.txt

curl --request GET lab.freecompilercamp.org:5010/sessions/bsk4ctgq4uig0s44264g/instances/bsk4ctgq_bsk4ctoq4uig0s442650/file?path=%2Fhome%2Ffreecc%2Ftest.txt

The URL pattern is <pwc_url>/sessions/<session_id>/instances/<instance_id>/file?path=<encoded file path>.
The parameter at the end is to indicate the demanding file. The file path after url encoding is the value of the key path.
The returned file content is encoded to Base64 format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant