I have a problem. In my project I get a text and send this text to remote API in .txt file. Now the program does this: getting a text, saving a text in a .txt file in filesystem, uploading a .txt file to remote API. Unfortunately, remote API accepts only files, I can't send plain text in request.
//get the wallPost with the field text
fs.writeFileSync(`./tmp/${wallPostId}.txt`, wallPost.text)
remoteAPI.uploadFileFromStorage(
  `${wallPostPath}/${wallPostId}.txt`,
  `./tmp/${wallPostId}.txt`
)
UPD: In function uploadFileFromStorage, I made a PUT request to remote api with writing a file. Remote API is API of cloud storage which can save only files.
const uploadFileFromStorage = (path, filePath) =>{
let pathEncoded = encodeURIComponent(path)
const requestUrl = `https://cloud-api.yandex.net/v1/disk/resources/upload?&path=%2F${pathEncoded}`
const options = {
  headers: headers
}
axios.get(requestUrl, options)
.then((response) => {
  const uploadUrl = response.data.href
  const headersUpload = {
    'Content-Type': 'text/plain',
    'Accept': 'application/json',
    'Authorization': `${auth_type} ${access_token}`
  }
  const uploadOptions = {
    headers: headersUpload
  }
  axios.put(
    uploadUrl,
    fs.createReadStream(filePath),
    uploadOptions
  ).then(response =>
    console.log('uploadingFile: data  '+response.status+" "+response.statusText)
  ).catch((error) =>
    console.log('error uploadFileFromStorage '+ +error.status+" "+error.statusText)
  )
})
But i guess in the future such a process will be slow. I want to create and upload a .txt file in RAM memory (without writing on drive). Thanks for your time.
 
    