Add Generic Properties to Document using documentService web service
I sucessfully been able to create nodes using the documentservice.asmx web service, but what I've not been able to figure out how to do is to fill the Generic Properties on the new content node that I've created.
What I've got so far creates the document, but say I've got a Generic Property called 'ServiceBulletin' which is an upload data type where I need to upload a pdf file to it.
How would I got about uploading the pdf doc into the 'Service Bulletin' property for new document I'm creating.
This is what I've got so far:
var document = new UmbracoDocumentService.documentCarrier(); document.Name = item.Name; document.DocumentTypeID = 1071; document.Published = true; document.ParentID = 1128; service.create(document, "username", "password");
I'm afraid with the file upload it is a bit more difficult. In the Umbraco backend it is an ASP FileUpload control that's used and Umbraco has it's own implementation to grab that file and put it in the correct directory in the system. If you want to upload a file yourself in the backend you have to populate the 'ServiceBulletin' property yourself with the correct path to the pdf file, yet you would have to program the whole file upload yourself I am afraid (which also means you can't use the documentservice.asmx web service :( ).
I am just in the process of writing a custom file upload for a new site, it takes a file the user has posted on the frontend and adds a new media item in the backend, here is a bit of code to highlight what I am talking about:
private Media CreateNewMediaItem(string fullClientFileName, string sourceFile, int fileLength) { try { MediaType mediaType = MediaType.GetByAlias("Film"); Media media = Media.MakeNew(txtTitle.Text, mediaType, new User(0), 1131);
//get the id of the umbracoFile property int id = media.getProperty("filmFile").Id; string destinationPath = Server.MapPath("~") + "media/" + id + "/";
if (!Directory.Exists(destinationPath)) Directory.CreateDirectory(destinationPath);
//copy over the file File.Copy(sourceFile, destinationPath + fullClientFileName);
Thanks for the reply...Fortunately I didn't have to go through all that.
My work around was to take the .pdf that I alre already had and used .net to write that directly to the file system. After that I wrote some code that built a link to the document and uploaded the link to my 'ServiceBulletin' upload property using documentservice.asmx.
That way our client still has the document upload data type that they require for manual upload, but the service that I've written can also download attachments from an email account that it monitors and upload the the link to the new document that has been written to file system.
Add Generic Properties to Document using documentService web service
I sucessfully been able to create nodes using the documentservice.asmx web service, but what I've not been able to figure out how to do is to fill the Generic Properties on the new content node that I've created.
What I've got so far creates the document, but say I've got a Generic Property called 'ServiceBulletin' which is an upload data type where I need to upload a pdf file to it.
How would I got about uploading the pdf doc into the 'Service Bulletin' property for new document I'm creating.
This is what I've got so far:
var document = new UmbracoDocumentService.documentCarrier();
document.Name = item.Name;
document.DocumentTypeID = 1071;
document.Published = true;
document.ParentID = 1128;
service.create(document, "username", "password");
Thanks,
dw
Hi dw,
I'm afraid with the file upload it is a bit more difficult. In the Umbraco backend it is an ASP FileUpload control that's used and Umbraco has it's own implementation to grab that file and put it in the correct directory in the system. If you want to upload a file yourself in the backend you have to populate the 'ServiceBulletin' property yourself with the correct path to the pdf file, yet you would have to program the whole file upload yourself I am afraid (which also means you can't use the documentservice.asmx web service :( ).
I am just in the process of writing a custom file upload for a new site, it takes a file the user has posted on the frontend and adds a new media item in the backend, here is a bit of code to highlight what I am talking about:
[I am using the nice Essential Objects AJAX Uploader, it will look a bit different with the standard ASP FileUpload]
Hope that helps,
Sascha
Thanks for the reply...Fortunately I didn't have to go through all that.
My work around was to take the .pdf that I alre already had and used .net to write that directly to the file system. After that I wrote some code that built a link to the document and uploaded the link to my 'ServiceBulletin' upload property using documentservice.asmx.
That way our client still has the document upload data type that they require for manual upload, but the service that I've written can also download attachments from an email account that it monitors and upload the the link to the new document that has been written to file system.
-dw
is working on a reply...