I am trying to use xmlrpc to create a node of type="file" but I dont think this module properly supports this. What I am doing is using the bitcache service hook to upload a file; this is working fine. However, when I try and create the node with type="file" it fails during the validation step because it is looking for an upload. Do you have any idea if I am doing something wrong or do you have any idea how to support creating a node this way.

Comments

darren.ferguson’s picture

IF you wanted to create a file over xmlrpc you can give the pertinent information then create the node like you would do any other

$node = new StdClass();
$node->type = 'file';

// any other information you want then
node_submit($node);

node_save($node);
rmh3093’s picture

what exactly is the "pertinent information" for a file node... in the context of what you have there I would assume I need something like:$node->file = .... but I am using java so I have the equivilant in java:

Map node = new TreeMap();
node.put("promote", false);
String title = "test file";
node.put("title", title);
node.put("type", "file");
HashMap file = new HashMap();
file.put("uri", "bitcache://"+uri);
node.put("file", file);
node.put("files", new Object[]{file});

but like I said above i get an error about not providing an upload file

miglius’s picture

You can try skipping looking for an upload if you already have a file in the bitcache and mimic the situation when a file node is not yet created, but the file is already uploaded, i.e. when a user clicks on the preview button instead of the save on the file node creation.

So, set a session variable like in the following example before saving a node:

$_SESSION['file_preview_file'] = (object)array('uri' => 'bitcache://13131313131', 'type' => 'video/mpeg', 'size' => 33333);

where size is in bytes and type is a file's MIME type. Don't forger to unset this session variable when you're done.

Let us know it it works.

rmh3093’s picture

I dont think I can set a session variable over xmlrpc, I had though about trying something like this. However, the only function xmlrpc gives me that I could imagine using is system.setVariable which takes 2 strings as parameters, im not sure how to do this

rmh3093’s picture

There should be a way to create a file node by specifying a uri to a bitstream, there should also be a hook or something to get the properties of the bitstream like the mime type and filesize so populate the proper file attributes in the file node

miglius’s picture

I have changed the module a little to allow creation of the file nodes when the file is uploaded to the bitcache. Use the latest dev version of the FileFramework. Then upload the file to the 'file' repository in bitcache. After that execute the following code to create a file node. The size and mime type will be extracted behind the scenes:

$node = (object) array('title' => 'the title of the node', 'type' => 'file', 'uid' => UID);
$node->file = (object) array('uri' => 'bitcache://HASH');
node_save($node);
miglius’s picture

Does it work?

rmh3093’s picture

excellent, no I havent tried it yet, but I will test it out tonight thanks!

rmh3093’s picture

actually, i think i could whip up an extension to the service module for this

rmh3093’s picture

how do specify which repo is used when i upload a bitstream?

miglius’s picture

Add

bitcache_use_repository(FILE_BITCACHE_REPOSITORY);

before saving the file in bitcache.

rmh3093’s picture

why not add that to the bitcache service hook so that I dont have to hack up a php module to do this ;)

ansorg’s picture

hi, this sounds like a solution to my issue: create file nodes from existing bitstream.

but how to add this to the user interface?

I'd like tho have an additional option on the "Create File" (/node/add/file) page to use an existing bitstream instead of browsing for a file locally.

Can the fileframework be extended to enable this?

thank you

Arto’s picture

Issue tags: +services, +Bitcache, +XML-RPC
johanneshahn’s picture

Status: Active » Closed (won't fix)

no activity