-1

I am trying to use download.file to extract a zip file from a URL and then push all the data in each of the files into a MySQL database. I am getting stuck in the first step where I use download.file to extract the zip file

I have tried the following but to no avail

myURL = paste("https://onedrive.live.com/download.aspx?cid=D700ACC18C0F37E6&resid=D700ACC18C0F37E6%2118670&ithint=%2Ezip",sep = "")
download.file(url=myURL,destfile=zippedFile, method='auto')

myURL = paste("https://onedrive.live.com/download.aspx?cid=D700ACC18C0F37E6&resid=D700ACC18C0F37E6%2118670&ithint=%2Ezip",sep = "")
download.file(url=myURL,destfile=zippedFile, method='curl')

Please suggest where am I going wrong. Also some pointers on how to take one file at a time from the zip folder and push into a DB will be most helpful

Sushanta Deb
  • 529
  • 8
  • 20

2 Answers2

2

What finally worked in AWS is the use of the package downloader

https://cran.r-project.org/web/packages/downloader/downloader.pdf

It has features to support https. Hope it will help someone

Sushanta Deb
  • 529
  • 8
  • 20
0

You can try this:

myURL = paste("https://onedrive.live.com/download.aspx?cid=D700ACC18C0F37E6&resid=D700ACC18C0F37E6%2118670&ithint=%2Ezip",sep = "")

dir = "zippedFile.zip"
download.file(myURL, dir, mode="wb")

destfile -- a character string with the name where the downloaded file is saved. Tilde-expansion is performed.

AK88
  • 2,946
  • 2
  • 12
  • 31
  • Your method will give error. Error in download.file(myURL, dir) : unsupported URL scheme – Sushanta Deb Aug 05 '17 at 04:42
  • I just added `mode="wb"` and now its working on my end. – AK88 Aug 05 '17 at 05:05
  • It works in my local machine but not when I run my R from AWS. Any suggestions – Sushanta Deb Aug 05 '17 at 06:01
  • I wish I could help, but I don't have any experience with AWS, sorry. – AK88 Aug 05 '17 at 06:03
  • @SushantaDeb Does your AWS machine has the SSL support in curl? I am not knowledgeable about R, but libcurl must be built with SSL support and openssl (or whatever SSL library is used) might need to be installed for it to work. Does `curl --help` list https as supported protocol on AWS? – user1643723 Aug 08 '17 at 05:19