[R] RCURL ftp upload - ASCII or Binary type?

Ben Tupper btupper at bigelow.org
Wed Sep 26 15:54:40 CEST 2012


Hi,

On Sep 26, 2012, at 8:07 AM, Magnus Eriksson wrote:

> I'm trying to upload a file using RCURL:s ftpUpload() to a ftp-server using the following command:
> 
>> ftpUpload("'VERY.ODD.FILE.NAME(+1)'",to="ftp://x.x.x.x/","' VERY.ODD.FILE.NAME(+1)'",userpwd="USER:PASSWORD")
> OK 
> 0
> 
> The file I'm trying to upload is a very simple text-file but with a bit weird filename. Note the ' on each side of the filename.
> 
> So the upload itself is successful but the receiver of the file tells me that the file I uploaded was of "Binary" type and that his system only accepts "ASCII". So the receiver can see the file but it contains only weird characters.
> 
> Surfing the web I found this:
> http://www.webweaver.nu/html-tips/ascii-binary.shtml
> 
> and indeed, when I try filezilla (http://filezilla-project.org/) to do the same upload, there is a setting in filezilla: "Default transfer type" that can be set to "ASCII" or "Binary". The transfer works fine when using "ASCII" and has same error as in R when using "Binary".
> 
> My conclusion is that, for some reason, R uses "Binary" as "Transfer type" here, but it should be using "ASCII".
> 
> I have been looking at curlSetOpt() but .encoding is not the problem here.
> 
> 
> Is there a way to change R:s "Transfer Type" from "Binary" to "ASCII" in this case? How?
> 

What happens if you explicitly set the asText argument to ftpUpload() to TRUE?  asText is defined by default based upon the 'what' argument.

> what = "'VERY.ODD.FILE.NAME(+1)'"
> asText = inherits(what, "AsIs") || is.raw(what)
> asText
[1] FALSE

So, maybe you need to set it to TRUE explicitly.  It's worth a try!

Cheers,
Ben




> 
> System: windows 7
> R version: 2.15.0
> 
> Thanks for your help
> 
> Best regards
> Magnus Eriksson
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
180 McKown Point Rd. P.O. Box 475
West Boothbay Harbor, Maine   04575-0475 
http://www.bigelow.org




More information about the R-help mailing list