Create media items in master database from CD server

I have a form in my application with file upload. On successfully submitting the form I need to create media items and save the data in sitecore master database. I have created a Web API controller and invoking the action methods from jquery to create content/media items in sitecore master database. I realized this will not work in CD server since master database is not accessible unless there is a definition for master database in delivery servers. 

I came across SSC(Sitecore Services Client) that I can use to create service in CM and access it from CD. I have few questions here,

  1. How to create a custom controller and invoke it from jquery as I am currently doing it using Web API controller?
  2. Is there a way to convert my existing Web API controller to Sitecore ServicesController?
  3. How to host this service in CM server and how to invoke it form CD server?
  4. What extra steps needs to be take care?
  • It is a good practice not to access authoring environment directly (neither connect to CM instance via HTTP, nor write directly to master database). The most clean way of achieving that is to create another copy of default master database and name it e.g. WebToMaster. This database (both as logical Sitecore database and physical SQL database) should be available to CM and CD instances, so CD instance creates a media item in this database via regular Sitecore Media API, and CM instance (CM1 if you have several CMs) listens to something like item:saved:remote event and as soon the event is dispatched - moves it to master (copies to master and deletes from WebToMaster).
  • Hi Vijay,

    We did same what you want to achieve.. in our case also we didn't have access of master db from CD server then we implemented this solution and it is working perfect for us. We have multiple CD's and still we are using the same solution.

    www.nttdatasitecore.com/.../Blog-Comments-without-web-service

    In this post we followed below steps -

    1. Created a custom database to store comment details.
    2. Added a connection string for custom database in connectionString.config file.
    3. Stored the comment details in custom database table.
    4. Created a Sitecore scheduler to migrate the data from Custom database to the Sitecore content tree.
    5. With the help of this approach we don’t need to tweak any of the security settings on the CD server.


    Hope this article can help you