file support 2

main
Antonio De Lucreziis 2 years ago
parent 931dedb79b
commit a2cd57c679

@ -9,7 +9,7 @@ app.use(express.json())
app.get('/api/status', c => c.json(42))
app.get('/api/container/:uuid([a-zA-Z0-9]+)/exec/ls', async (req, res) => {
app.get('/api/container/:uuid([a-zA-Z0-9-]+)/exec/ls', async (req, res) => {
const uuid = req.params.uuid
try {
@ -21,14 +21,14 @@ app.get('/api/container/:uuid([a-zA-Z0-9]+)/exec/ls', async (req, res) => {
}
})
app.get('/api/container/:uuid([a-zA-Z0-9]+)/fs/*', async (req, res) => {
app.get('/api/container/:uuid([a-zA-Z0-9-]+)/fs/*', async (req, res) => {
const uuid = req.params.uuid
const path = req.params[0]
console.log('Getting', path)
try {
const content = await runCommand('docker', ['exec', uuid, '/bin/cat', '/' + path])
const content = await runCommand('docker', ['exec', uuid, '/bin/cat', `/project/${path}`])
res.json(content)
} catch (e) {
@ -36,14 +36,14 @@ app.get('/api/container/:uuid([a-zA-Z0-9]+)/fs/*', async (req, res) => {
}
})
app.put('/api/container/:uuid([a-zA-Z0-9]+)/fs/*', async (req, res) => {
app.put('/api/container/:uuid([a-zA-Z0-9-]+)/fs/*', async (req, res) => {
const path = req.params[0]
const content = req.body
console.log(content)
try {
await runCommand('docker', ['exec', uuid, '/bin/sh', '-c', `cat - > "${path}"`], {
await runCommand('docker', ['exec', uuid, '/bin/sh', '-c', `cat - > "/project/${path}"`], {
stdin: content,
})