Upload library assets

‘ Dim myFile2 = FileName.Text.ToLower
Dim myFile As HttpPostedFile = DMSfile.PostedFile

‘add myDMSAssets as folder in site root directory
DMSfile.PostedFile.SaveAs(Server.MapPath("~/path/") & myFile.FileName)

Dim fs As New System.IO.FileStream(Server.MapPath("~/path/" & myFile.FileName), IO.FileMode.Open)

Dim UpdateFile As New Ektron.Cms.AssetUpdateData

UpdateFile.FileName = myFile.FileName
UpdateFile.LanguageId = 1033
‘add a folder in the WorkArea for DMS documents
UpdateFile.FolderId =
UpdateFile.Title = myFile.FileName & " " & Date.Now()
UpdateFile.EndDate = Date.Now.AddMonths(6)
UpdateFile.Teaser = "Name: " & txtName.Text & "
Dim dmsURL As String = "
"
Dim contentAPI As New Ektron.Cms.API.Content.Content

Dim dmsID As Integer = contentAPI.AddAsset(fs, UpdateFile)

System.IO.File.Delete(Server.MapPath("~/path/" & myFile.FileName))

Dim myContentBlock As New Ektron.Cms.Controls.ContentBlock
myContentBlock.DefaultContentID = dmsID
myContentBlock.Page = Page
myContentBlock.Fill()

Dim myAsset As New Ektron.Cms.API.Content.Asset
dmsURL = myAsset.GetViewUrl(myContentBlock.EkItem.AssetInfo.Id, 0)

<div id="_mcePaste">Name: &lt;asp:TextBox ID="txtName" runat="server" /&gt;</div>
<div id="_mcePaste"></div>
<div id="_mcePaste">&lt;p runat="server" id="DMSUpload" visible="true"&gt;</div>
<div id="_mcePaste">&lt;asp:Label ID="DMSlabel" runat="server" AssociatedControlID="DMSfile" Text="Select File:" /&gt;</div>
<div id="_mcePaste">&lt;asp:FileUpload ID="DMSfile" runat="server" /&gt;</div>
<div id="_mcePaste">&lt;asp:RegularExpressionValidator ID="DMSreg" runat="server"</div>
<div id="_mcePaste">ControlToValidate="DMSfile"</div>
<div id="_mcePaste">ValidationExpression="^.+\.(doc)$"</div>
<div id="_mcePaste">ErrorMessage="resume can only be in .doc format" /&gt;</div>
<div id="_mcePaste">&lt;/p&gt;</div>
<div id="_mcePaste">&lt;asp:Button ID="btnAddDMS" runat="server" Text="Upload" /&gt;</div>
Name: &lt;asp:TextBox ID="txtName" runat="server" /&gt;    &lt;br /&gt;    Desired Position: &lt;asp:TextBox ID="txtPosition" runat="server" /&gt;    &lt;br /&gt;    Brief Summary: &lt;asp:TextBox ID="txtSummary" runat="server" /&gt;    &lt;p runat="server" id="DMSUpload" visible="true"&gt;            &lt;asp:Label ID="DMSlabel" runat="server" AssociatedControlID="DMSfile" Text="Select Resume:" /&gt;            &lt;asp:FileUpload ID="DMSfile" runat="server" /&gt;            &lt;asp:RegularExpressionValidator ID="DMSreg" runat="server"                 ControlToValidate="DMSfile"                ValidationExpression="^.+\.(doc)$"                ErrorMessage="resume can only be in .doc format" /&gt;        &lt;/p&gt;                &lt;asp:Button ID="btnAddDMS" runat="server" Text="Upload" /&gt;
This entry was posted in Ektron. Bookmark the permalink.

One Response to Upload library assets

  1. Candace says:

    Hi, do you happen to have this code in c#? I am looking for this type of function. Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>