I'm doing a custom import of old data from a old umbraco site, and for that reason I need to create some nodes from code.
I've got creation of documents and setting of ordinary properties nailed, but I don't know how to go about population properties of datatype upload. How do you go about this?
I don't know syntax by heart, but would suggest to do following:
create a upload datatype on a test document, upload some file, and have a look at the generated xml in the umbraco.config (when published of course). i'm sure you'll need to first create a media item, and fill upload datatype's value for the document with an xml snippet that represents the media node.
Your import comes a few months too early. This functionality is top prio for UmbImport 1.1. I've build this myself for a client (I don't have the source anymore) and what I did was downloading the Umbraco Source code and reverse engineered the Upload Datatype. It's kinda difficult because its generatiing thumbnails, creating folders etc.
I was afraid that it wasn't easy (since it wasn't already in the umbimport package) - was looking into figuring out how to do it by going through the source code. But it looks like a long haul to get there :(
It depends of how to save the file. Should it be available in the media lib or is it a pure upload field. In the second case you only have to upload the file into the correct folder and populate the filepath to the property value:
var newDoc = Document.MakeNew("MyNewDocument", new DocumentType(1234), new User(0), 5678); var fileUploadProperty = newDoc.getProperty("MYPROPERTYALIAS"); var mediaId = fileUploadProperty.Id; var folder = Server.MapPath(string.Format("/media/{0}", mediaId)); if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); //SAVE THE FILE TO THE FOLDER... string targetFilename = string.Format("/media/{0}/{1}", mediaId, YOURFILENAME); string targetFilepath = Server.MapPath(targetFilename); fileUploadProperty.Value = targetFilepath; newDoc.Publish(new User(0)); umbraco.library.UpdateDocumentCache(newDoc.Id);
yes, I have implemented such things for our intranet and on some other private projects. In our intranet and extranet I have implemented some windows forms clients which are connecting via webservices to the umbraco installations uploading files like press releases, things that the users have to do once a day and where the users are tired to login into the umbraco backend. Do you need a hand?
Thanks a lot. I've done a couple of test runs now, and it looks promising.
The data is there without the thumbnail, which isn't a big problem. Now I just need to put some finishing touches on the code to handle inconsistencies in the source data, before I can get it up and running.
Create document attached file
I'm doing a custom import of old data from a old umbraco site, and for that reason I need to create some nodes from code.
I've got creation of documents and setting of ordinary properties nailed, but I don't know how to go about population properties of datatype upload. How do you go about this?
Regards
Jesper Hauge
Jesper,
I don't know syntax by heart, but would suggest to do following:
create a upload datatype on a test document, upload some file, and have a look at the generated xml in the umbraco.config (when published of course). i'm sure you'll need to first create a media item, and fill upload datatype's value for the document with an xml snippet that represents the media node.
Does that make sense?
Cheers,
/Dirk
Hi Jesper,
Your import comes a few months too early. This functionality is top prio for UmbImport 1.1. I've build this myself for a client (I don't have the source anymore) and what I did was downloading the Umbraco Source code and reverse engineered the Upload Datatype. It's kinda difficult because its generatiing thumbnails, creating folders etc.
Cheers,
Richard
Hi Richard
I was afraid that it wasn't easy (since it wasn't already in the umbimport package) - was looking into figuring out how to do it by going through the source code. But it looks like a long haul to get there :(
Thanks for your reply.
Cheers
Jesper
It depends of how to save the file. Should it be available in the media lib or is it a pure upload field. In the second case you only have to upload the file into the correct folder and populate the filepath to the property value:
hth, Thomas
Thanks Thomas - that sounds great I will try it out!
Do you have personal experience doing something like this?
Regards
Jesper Hauge
yes, I have implemented such things for our intranet and on some other private projects. In our intranet and extranet I have implemented some windows forms clients which are connecting via webservices to the umbraco installations uploading files like press releases, things that the users have to do once a day and where the users are tired to login into the umbraco backend. Do you need a hand?
Thomas
Hi again
Thanks a lot. I've done a couple of test runs now, and it looks promising.
The data is there without the thumbnail, which isn't a big problem. Now I just need to put some finishing touches on the code to handle inconsistencies in the source data, before I can get it up and running.
Thanks again.
Cheers
Jesper Hauge
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.