View Issue Details

IDProjectCategoryView StatusLast Update
0011151mantisbtapi soappublic2010-07-29 10:45
Reportermagnomp Assigned Torombert  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.1.8 
Target Version1.2.2Fixed in Version1.2.2 
Summary0011151: Can't upload attachment to issue via soap interface
Description

Attachments sent to issues through the soap interface are always empty. I mean: The attachment do appear on the issue page, but with size = 0.

My attachments are stored on database. I haven't tried this with other methods.

Steps To Reproduce

Call mc_issue_attachment_add to upload any file to an existing issue.

Additional Information

I noticed the mc_issue_attachment_add implementation calls base64_decode to decode the attachment data. I removed the call to base64_decode and now it works.
I'm not an expert on PHP, neither on NuSoap, but I did some investigation on NuSoap code, and it looks like it already decodes all of the base64 parameters before calling the webservice implementation, so it must not be decoded again.

Here's my modified version of mc_issue_attachment_add:
function mc_issue_attachment_add( $p_username, $p_password, $p_issue_id, $p_name, $p_file_type, $p_content ) {
$t_user_id = mci_check_login( $p_username, $p_password );
if ( $t_user_id === false ) {
return new soap_fault( 'Client', '', 'Access Denied' );
}
if ( !file_allow_bug_upload( $p_issue_id, $t_user_id ) ) {
return new soap_fault( 'Client', '', 'Access Denied' );
}
if ( !access_has_bug_level( config_get( 'upload_bug_file_threshold' ), $p_issue_id, $t_user_id ) ) {
return new soap_fault( 'Client', '', 'Access Denied' );
}
return mci_file_add( $p_issue_id, $p_name, $p_content, $p_file_type, 'bug' );
}

I also suggest to change the documentation regarding $p_content parameter, as it says it's base64, when the function actually receivess binary data.

TagsNo tags attached.

Relationships

duplicate of 0010235 closedgiallu mc_issue_attachment_add corrupts attachments 

Activities

rombert

rombert

2009-11-10 15:09

reporter   ~0023642

The client must sent base64 encoded content, as specified by the WSDL. It will then be decoded by NuSOAP.

magnomp

magnomp

2009-11-10 16:11

reporter   ~0023644

Are you sure it's a duplicate of 0010235? The issue page says it has been fixed in 1.1.7, but I've experienced it on 1.1.8

rombert

rombert

2009-11-10 16:25

reporter   ~0023645

I am sure since as a developer of the Mylyn-Mantis connector, which uses the SOAP API, have tested ( and have workarounds ) for both 1.1.6 ( pre-fix ) and 1.1.7 ( post-fix ).

magnomp

magnomp

2009-11-10 16:47

reporter   ~0023647

Have you tested with 1.1.8? Perhaps the bug has been reintroduced, or maybe it's a new bug which happens to have the same symptoms. But I'm sure this feature isn't working on 1.1.8.

The data is already being sent base64 encoded, I've intercepted the soap request to check it.

The problem here is that the decoding is hapenning twice: First inside NuSOAP, and then inside mc_issue_attachment_add implementation.

As the seccond base64_decode call receives raw binary data, it returns nothing.

rombert

rombert

2009-11-10 17:25

reporter   ~0023648

I'll take a closer look then.

hallids

hallids

2010-03-28 23:08

reporter   ~0024916

Last edited: 2010-03-28 23:21

I have encountered the same issue in Mantis version 1.2.0. It seems like this issue is a duplicate of 0010235 yet it still exists in 1.2.0.

As magnomp said, the fix was to remove the call to base64_decode() in the mc_issue_attachment_add() function.

rombert

rombert

2010-04-05 15:48

reporter   ~0025037

I was able to reproduce this using the SOAP UI. I am not sure why both the PHP tests and the Eclipse integration worked, but this is a bug and I will fix it.

rombert

rombert

2010-04-28 14:43

reporter   ~0025333

I've committed a fix in the soap-attachments branch ( commit at http://git.mantisbt.org/?p=mantisbt.git;a=commit;h=b836b267cfc77aa516968fe05d1804743df133d7 ). Please verify that it does solve the problem you've reported.

Related Changesets

MantisBT: master dd284661

2010-04-28 14:25

rombert


Details Diff
Only decode attachments once when using the SOAP API

Attachments uploaded using the SOAP API calls are decoded by NuSOAP. Up till
now, we are also decoding the attachments, which caused the attached files
to be unreadable.

Although workarounds do exist, the correct way is to let NuSOAP apply the
Base64-decoding. The requirement for the users of the SOAP API is to
Base64-encode the attachments passed to mc_issue_attachment_add
mc_project_attachment_add and to Base64-decode the attachments retrieved
with mc_issue_attachment_get and mc_project_attachment_get.

Fixes 0011151: Can't upload attachment to issue via soap interface
Affected Issues
0011151
mod - api/soap/mc_issue_attachment_api.php Diff File
mod - api/soap/mc_project_attachment_api.php Diff File
mod - tests/soap/AttachmentTest.php Diff File

MantisBT: master-1.2.x d04d8ea5

2010-04-28 14:25

rombert


Details Diff
Only decode attachments once when using the SOAP API

Attachments uploaded using the SOAP API calls are decoded by NuSOAP. Up till
now, we are also decoding the attachments, which caused the attached files
to be unreadable.

Although workarounds do exist, the correct way is to let NuSOAP apply the
Base64-decoding. The requirement for the users of the SOAP API is to
Base64-encode the attachments passed to mc_issue_attachment_add
mc_project_attachment_add and to Base64-decode the attachments retrieved
with mc_issue_attachment_get and mc_project_attachment_get.

Fixes 0011151: Can't upload attachment to issue via soap interface
Affected Issues
0011151
mod - api/soap/mc_issue_attachment_api.php Diff File
mod - api/soap/mc_project_attachment_api.php Diff File
mod - tests/soap/AttachmentTest.php Diff File