views:

21

answers:

2

I'm currently working on a Flash application that needs to save files to Drupal. I already saved the file to the Drupal site with the File service, but I can't get to attach the file to the node with the node.save service (Upload module, not CCK file field).

The object that I will transfer with node.save looks like this in AS3 :

var node:Object;
// all the other required node fields : nid, type, language, uid, name,
// status, title, changed, created, format, taxonomy, picture
node.files = new Array();

var aFile:Array = new Array;
aFile['list']=1;
aFile['weight']=0;
aFile['remove']=0;
aFile['description']="test.txt";

// id = id of the previously saved file
node.files[id] = aFile;

I guess there's some fields missing or something like that.

A: 

Perhaps your issue has to do with your aFile Array. To create an associative array in AS3 Adobe suggests you use an Object:

var aFile:Object = new Object();
aFile['list']=1;
aFile['weight']=0;
aFile['remove']=0;
aFile['description']="test.txt";

// id = id of the previously saved file
node.files[id] = aFile;

From Adobe documentation:

  • "Do not use the Array class to create associative arrays (also called hashes), which are data structures that contain named elements instead of numbered elements. To create associative arrays, use the Object class. Although ActionScript permits you to create associative arrays using the Array class, you cannot use any of the Array class methods or properties with associative arrays."
heavilyinvolved
I'm not using any Array class functions. I use the array/Object only as a data structure that will be given to amfphp.I still tried it with no success. Ty for the suggestion.
Nezrak
A: 

I found it actually concerns only modules who modify data directly in the object loaded with node_load() before saving it with node_save(). Other modules (like CCK) act on the #post data of the form (with drupal_execute).

The service module needs a patch to be able to handle the upload module (or any module like this one).

You can follow the details on the ticket I have opened here http://drupal.org/node/881740

Nezrak