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
Comment #1
darren.ferguson commentedIF you wanted to create a file over xmlrpc you can give the pertinent information then create the node like you would do any other
Comment #2
rmh3093 commentedwhat 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
Comment #3
miglius commentedYou 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.
Comment #4
rmh3093 commentedI 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
Comment #5
rmh3093 commentedThere 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
Comment #6
miglius commentedI 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:
Comment #7
miglius commentedDoes it work?
Comment #8
rmh3093 commentedexcellent, no I havent tried it yet, but I will test it out tonight thanks!
Comment #9
rmh3093 commentedactually, i think i could whip up an extension to the service module for this
Comment #10
rmh3093 commentedhow do specify which repo is used when i upload a bitstream?
Comment #11
miglius commentedAdd
before saving the file in bitcache.
Comment #12
rmh3093 commentedwhy not add that to the bitcache service hook so that I dont have to hack up a php module to do this ;)
Comment #13
ansorg commentedhi, 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
Comment #14
Arto commentedComment #15
johanneshahn commentedno activity