jasonleibowitz/react-add-to-calendar-hoc

Outlook/ICal not initiating download of .ics file

waynemcmahon opened this issue · 3 comments

Bug report

When clicking Outlook or iCal it opens the following url in the browser and doesn't download the .ics file. It should be noted that when I use your examples that it does download the file

begin:VCALENDARVERSION:2.0BEGIN:VEVENTURL:http://localhost:3000/go/checklistMETHOD:PUBLISHDTSTART:20200219T111924ZDTEND:20200219T131924ZSUMMARY:Get records of your superannuation / pension contributionsDESCRIPTION:There are situations when having a record of your superannuation / pension contributions could come in handy. Get these records before you leave, just in case you need them when you’re in Canada.LOCATION:NYCEND:VEVENTEND:VCALENDAR

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Click Add to calendar
  2. Click Outlook
  3. Should download file but instead opens the url in browser

Can you provide additional information regarding what browser and operating system you used? Additionally, since you say that when you click to download the Outlook or iCal link from the examples it does work, can you also provide some code examples? Maybe there's an issue there.

Closed as stale

@jasonleibowitz thanks for providing this lib, saved me a lot of hassle.

I ran into somewhat similar problem with Outlook ics download, as mentioned by @wakomako here.
Everything works fine and Outlook ics gets downloaded on local server, but when I pushed my app to SharePoint Online, instead of downloading ics file, it tries to open an URL -
https://mycompany.sharepoint.com/sites/Event/blob:/bf5e3e03-9bb7-486c-b29b-6bd8c8d3835e and gives 404 NOT FOUND error. (my app home url is somewhat like - https://mycompany.sharepoint.com/sites/Event/SitePages/Event2020.aspx)

So I digged down the lib code and found this line -
link.href = window.URL.createObjectURL(blob);

After a bit of Googling around, I changed this line to -
link.href = 'data:text;charset=utf-8,' + encodeURIComponent(url);

With this change, now the Outlook ics gets downloaded properly on local as well as on SharePoint Online.