ouankou / llnl-work-notes

Record TODO, Work-in-Progress and Done tasks in LLNL.
GNU Affero General Public License v3.0
0 stars 0 forks source link

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

Closed ouankou closed 4 years ago

ouankou commented 4 years ago

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 commented 4 years ago

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.