There are plans to implement an API to upload files? I need to do a script to migrate from other CMS to Drupal and I don't know from where I need to begin hehe..

If you give me a clue, I could try to make an API.

Comments

geoff_eagles’s picture

Hi Mariano,
You're still trying to import your ezPublish data??
I'm afraid dbFM doesn't have an API as such. Its initial development was a little haphazard - it evolved from another module (webFM) rather than being designed from the ground up. Perhaps I'll be able to clean things up a little for the D7 release?
I imagine all you need is a simple module to read each record in your ezPublish database table and create an entry in the dbfm_file table and a corresponding entry in the dbfm_data table. The easiest way to automate it would be to give every file the same parent directory and then manually move the files into a more appropriate directory structure later.
Take a look at the dbfm_form_upload_submit code where I fill in the metadata for the dbfm_file record then compress the file itself and shove it into the dbfm_data record.
Get in touch if you're struggling

Manonline’s picture

Yes, I'm with the import from eZ, with some brakes in the middle, but now I'm fully dedicated to the migration.

Now I'm doing a module to do the file import, but I'm in trouble trying to get the filesize. I don't have the file in the filesystem, I have it in a variable.

geoff_eagles’s picture

Doesn't ezPublish record the file size somewhere?
If not you're going to have to get the file out of the ezPublish database blob before you compress it - you can see how big it is then?

Manonline’s picture

I can download them to filesystem and get the size with filesize(), but there are 25.000 files and I'm trying to avoid that :P

geoff_eagles’s picture

When you get your blob into a variable (prior to compressing it) can't you just measure the length of it?
e.g $ezfilecontents = $ezPubRec->ezblob;
$ezfilesize = strlen($ezfilecontents);
I'm still surprised that ezPublish doesn't save the filesize.

Manonline’s picture

YES! eZ does, eZ save the filesize. My mystake! I didn't look well -.-

Now I'm finishing the query to get the filedata and nid from an eZNID.

When finished, I'll upload the script and querys, may be it be usefull for other people :)

Manonline’s picture

StatusFileSize
new4.02 KB

Well... here is the module.

Is a mapper for the Feeds module (using filefield mapper as guide), in that module, I include a posible generic function for upload files for DBFM.

Can you review the code and tell me if I'm missing something?

If you like the Feeds integration, feel free to use it :)

Manonline’s picture

StatusFileSize
new1.22 KB

There are some errors in the attach function. Here is the patch.

geoff_eagles’s picture

Thanks for sharing your work, though I'm a bit pushed for time to have a really good look at it at the moment - I've not come across the Feeds module before.
My company's just been taken over so there's too much to read and do just now! I hope your solution works well and don't forget to post if you come across any more problems.

Manonline’s picture

StatusFileSize
new14.12 KB

Here is mi work finished and working :)