BuddhaNexus / buddhanexus

Backend for the Buddhanexus project
8 stars 2 forks source link

Download Table & Numbers view not working #276

Open ayya-vimala opened 2 months ago

ayya-vimala commented 2 months ago

After the backend merging of #245 the backend returns a BytesIO object for download. This breaks the frontend functionality so the frontend needs to be re-setup. See the docs for the correct output link.

Care should be taken that the download_data='' parameter is set to table or numbers depending on which view is requested for download.

ayya-vimala commented 3 weeks ago

Most likely what is needed here is just to call the API without expecting a response. That should automatically download things to the user's downloads folder. Add the additional output parameter to the curl like for instance --output 'Downloads/buddhanexus-table.xlsx' \. This can also include the actual filename and type of table requested (table or numbers). Something like this: --output 'Downloads/buddhanexus_numbers_PA_dn_1.xlsx' \


curl -X 'POST' \
  'http://dharmamitra.org:8001/api-db/download/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  --output 'Downloads/buddhanexus-table.xlsx' \
  -d '{
  "filename": "PA_dn_1",
  "filters": {
    "par_length": 30,
    "score": 30,
    "languages": [
      "all"
    ],
    "include_files": [
      "PA_dn_2"
    ]
  },
  "page": 0,
  "sort_method": "position",
  "folio": "",
  "download_data": "table"
}'```
ayya-vimala commented 3 weeks ago

Should be working now by just calling the API

aminahbl commented 3 weeks ago

https://discord.com/channels/1229483442203263056/1288619105292648488/1298562977976287243

ayya-vimala commented 4 days ago

Just noticed there is simply no button on the frontend for download. The button should be in the right sidebar under Options tab for the Numbers View and Table View but NOT for the Text view. Right now it erroneously shows in Text View and it downloads a file without extension. So best to make it something like filename_table.xlsx or filename_numbers.xlsx Note that the extension is xlsx