Bug 26312 - webClient.UploadFile(ftpPath, filePath) adds some header information to the uploaded file.
Summary: webClient.UploadFile(ftpPath, filePath) adds some header information to the u...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: General ()
Version: 3.4.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-01-22 19:51 UTC by Jon Goldberger [MSFT]
Modified: 2015-02-20 09:25 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test Project (8.79 KB, application/zip)
2015-01-22 19:53 UTC, Jon Goldberger [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jon Goldberger [MSFT] 2015-01-22 19:51:28 UTC
## Description

When uploading a file to an ftp server using WebClient.UploadFile(ftpPath, filePath) there are 3 lines of the header added to the beginning of the uploaded file. I tested this using a server running vsftp from both a Mono console project (using Xamarin Studio on a Mac) and a .NET console project (using Visual Studio). When running the same code with .NET, there is no extra text at the start of the file. 

## steps to reproduce:

1. Open the attached test project in Xamarin Studio (Mac)
2. set the four variables for the filepath, username, password, and ftphost. Obviously the ftp host must be a live ftp server with a user with the username and password you enter. There is a simple two line text file, testfile.txt. in the project folder.
3. Run the project.
4. Inspect the uploaded file.

Expected result: the uploaded file will be identical to the original file.

Actual result: the uploaded file has three lines appended to the beginning of the file that appear to be header information, e.g.:
--------------8d204657a3c5604
Content-Disposition: form-data; name="file"; filename="testfile.txt"
Content-Type: application/octet-stream


## Note:

Running the identical code in a Visual Studio C# Console project, but of course modifying the path to the text file for Windows environment, the uploaded file is identical to the original file.
Comment 1 Jon Goldberger [MSFT] 2015-01-22 19:53:48 UTC
Created attachment 9456 [details]
Test Project
Comment 3 Miguel de Icaza [MSFT] 2015-01-23 00:33:46 UTC
Fix and test cases are available here:

https://gist.github.com/migueldeicaza/04e3f5619af8c7b4b9a6

This can not be applied to master, which has the Microosft implementation.

But this can be applied to a branch if we need to.
Comment 5 Ram Chandra 2015-02-20 09:25:36 UTC
I have checked this issue with Mono: 3.12.0.77 and observed that now the uploaded file is identical to the original file.

Mac OS X 10.10.0
Xamarin Studio: 5.7.2 (build 10)
Installation UUID: 6ea47b0d-1852-4aaf-808d-373ff0a5002b
Mono 3.12.0 ((detached/b8f5055)
GTK+ 2.24.23 (Raleigh theme)
Package version: 312000077
=== Build Information ===
Release ID: 507020010
Git revision: 52601676108dae9f012b5e8378a3d6e742143e16
Build date: 2015-02-19 18:25:24-05
Xamarin addins: b212fd66838b0d6e2435966e541e66ab9c988698

Screencast: http://www.screencast.com/t/R5YzwlX6

Observation: I have checked this issue with attached project and observed that when I upload a file to an ftp server using WebClient.UploadFile(ftpPath, filePath), not extra values are added to the file. The uploaded file is identical to the original file.

This issue has been fixed. Hence I am closing this issue.