I am trying to upload a file as cck attachment to a new node using JSON_RPC service. The file gets uploaded to the Drupal file system but it's blank, 0 byte file. I think problem lies somewhere in encoding and may be it's a TI api issue. I submitted a question"How to convert a Titanium Blob to string?" on their forum but also want to check with the Drupal community and see if anybody else faced the same issue. Here is the code
function upload_image(media){
//the file i want to send
var file = {
file: Test,
filename: "test27.jpeg",
filepath: "files/test27.jpeg",
filesize: media.size,
timestamp: String(date.getTime()),
uid: uid,
status: 0,
filemime: ".jpeg"
};
//the args i send i the jsonrpc
var args = {
file: file
};
//a basic fonction give the method the args calculate the hash ...
jsonrpc.request("file.save", args, function(){
Titanium.API.info(this.responseText);
information = eval('(' + this.responseText + ')');
Titanium.API.info(information.result);
var node = {
type: "image",
title: "image upload",
field_image: {
fid: information.result,
filemime: ".jpeg",
filesize: media.size,
timestamp: String(date.getTime()),
uid: uid,
status: 1,
list: 1,
filename: "test27.jpeg",
filepath: "files/test27.jpeg"
}
};
args = {
node: node
};
//saving the node
jsonrpc.request("node.save", args, function(){
Titanium.API.info(this.responseText);
information = eval('(' + this.responseText + ')');
Titanium.API.info(information);