petko_stankoski
petko_stankoski

Reputation: 10713

Uploading zip file. When downloading, it's corrupt

I'm uploading a zip file to Bugzilla with the following code:

bug.AppendAttachment("someComment", "application/octet-stream", "somedata",
"filePath", bugId, false, false, false, "someSummary");

The false parameters are: 1. is_Url 2. is_patch 3. is_private

The file is uploaded, and when I login to Bugzilla and download id, a message appears which says it's corrupted or damaged and cannot be opened. Why is this happening? When I'm uploading it by hand, everything is ok.

Upvotes: 0

Views: 1522

Answers (1)

ziesemer
ziesemer

Reputation: 28687

We need to see your addition of AppendAttachment to further answer this. However, per http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html#add_attachment, you need to ensure that whatever you're passing to "data" is properly Base64-encoded.

If somedata is what you are directly passing to data, you need to first encode your binary data (the Zip file) to Base64 using http://msdn.microsoft.com/en-us/library/dhx0d524.aspx.

If you attempt to store your binary data as a String at any point before encoding it with Base64, you will corrupt your payload.

Upvotes: 2

Related Questions