https://discord.gg/botpress logo
code works only in emulator
# 🤝help
l
I am uploading a file and then extracting few details of the file from botpress files, before further processing it. It works perfect in the Emulator, however fails to run in webchat >
Copy code
let filePath = workflow.fileName
> console.log('Received File ', filePath)
> if (filePath.startsWith('https//')) {
>   filePath = filePath.replace('https//', 'https://')
> }
> try {
>   const res = await client.listFiles({
>     tags: {
>       purpose: 'emulator'
>     }
>   })
>   const files = res.files
>   console.log('files ', files)
> 
>   for (let file of files) {
>     console.log('file.url : ', file.url)
>     console.log('filePath : ', filePath)
>     if (file.url?.toLowerCase().trim() === filePath?.toLowerCase().trim()) {
>       const fileName = file.key
>       console.log('Matching File Found : ', fileName)
>       const cleanFilename = fileName.substring(fileName.indexOf('.') + 1)
>       console.log('File Name ', cleanFilename)
> 
>       const response = await axios.post(
>         hookURL,
>         {
>           filename: cleanFilename,
>           filepath: filePath
>         },
>         {
>           headers: {
>             'Content-Type': 'application/json'
>           }
>         }
>       )
>       console.log('Response : ', response.data)
>       workflow.hookResponse = response.data
>       break
>     }
>   }
> } catch (error) {
>   console.error('Error fetching files: ', error)
> }
https://cdn.discordapp.com/attachments/1360844064844415076/1360844593113071666/image.png?ex=67fc98ca&is=67fb474a&hm=942ee0bdbdf59c39815030f2767fbbddb8cfc4cd0ee4ae7e2bd7039da476e509& https://cdn.discordapp.com/attachments/1360844064844415076/1360844593549283399/image.png?ex=67fc98ca&is=67fb474a&hm=d1858baf50328e3488c3b75ceecd6d817bce14407391d52bab2cff0fe993be3d&