How to upload file from host to lxc using resp api?

function fileUpload(name) {
  const form = new FormData();
  form.append('file', fs.createReadStream('./test.yaml')) + "/1.0/instances/"+name+"/files?path=%2Froot%2F.config%2Fcode-server%2Ftest.yaml", form)
    .then(res => {
    .catch(err => {

this function create empty file at specified path but I want to copy file from host to lxc

Make sure that you push the content with content-type set to application/octet-stream so that LXD can handle it properly.

1 Like