Adding new folder and share directly to DB


I have my own Project Management System, which is on internal network. I would like to:

  • create new folder for new project, visible by owncloud - already done, folders are on external CIFS.
  • create new share in oc_share table - working on it

What I see is that I need unique object_id to make working entry to oc_share, which is also available in oc_activity. Not sure hoverer if cron is updating the activity when folder was added from outside of owncloud…

Has anyone done this before? Any tips?

I can see that there is OC SHARE API available, but I was unsuccessful using that and could not find any tutorial or explanation.


Hi Adam,

I’d rather not bother with direct db inserts, unless you really know, what you are doing.

Did you find the OCS Share API Documentation?
There are pretty code examples how to create shares.
The linked example shows how to share a certain path:


Couple of important things:

  1. Create the folder through ownCloud via webdav interface.
  2. Create the share in ownCloud via share API.

Touching the DB directly, not only won’t work, but also will break other things. Never touch the DB unless people from ownCloud tell you there is no other option to fix something (which isn’t the case)

As said by Cortho, check the documentation. If there is something that isn’t clear, post your doubt and link to the piece of documentation that isn’t clear enough so people can double-check that piece and improve it if needed.


Thanks guys for your tips!

I was working on my own all day yesterday and wrote a script, that checks oc_filecache table for my new folders (which were added by cron oc file_scan) and gets the variable, having that I’m able to generate share entries to db - structure of the oc_share table is explained in my first link.

Generally it is quite straight forward - owncloud db is very logical and when it comes to shares - there is only one table for that.

Summit it up - everything works like a charm!