From 6045d88f643b912672bb1f2bc12048ae57fd2249 Mon Sep 17 00:00:00 2001
From: Robert Munteanu <robert.munteanu@gmail.com>
Date: Sun, 16 May 2010 19:07:04 +0300
Subject: [PATCH] Fix attachment upload for SOAP API/PostgreSQL

Using database attachments and the SOAP API was broken when using
PostgreSQL as the database. The code now uses the same query as in
file_api.php

Fixes #11590: Couple of bugs in api/soap/mc_file_api.php - mc_file_add()
---
 api/soap/mc_file_api.php |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/api/soap/mc_file_api.php b/api/soap/mc_file_api.php
index a354453..b8a4e60 100644
--- a/api/soap/mc_file_api.php
+++ b/api/soap/mc_file_api.php
@@ -107,7 +107,7 @@ function mci_file_add( $p_id, $p_name, $p_content, $p_file_type, $p_table, $p_ti
 			}
 			break;
 		case DATABASE:
-			$c_content = db_prepare_string( $p_content );
+			$c_content = db_prepare_binary_string( $p_content );
 			break;
 	}
 
@@ -116,7 +116,7 @@ function mci_file_add( $p_id, $p_name, $p_content, $p_file_type, $p_table, $p_ti
 	$query = "INSERT INTO $t_file_table
 			(" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content)
 		VALUES
-			($c_id, '$c_title', '$c_desc', '$c_disk_file_name', '$c_new_file_name', '$c_file_path', $c_file_size, '$c_file_type', '" . db_now() . "', '$c_content')";
+			($c_id, '$c_title', '$c_desc', '$c_disk_file_name', '$c_new_file_name', '$c_file_path', $c_file_size, '$c_file_type', '" . db_now() . "', $c_content)";
 	db_query( $query );
 
 	# get attachment id
-- 
1.7.1

