I have a document type which has attachment in form of .png and .xlm files. A table which has this document fields has this attachment guid stored in it.
I want to update an attachment file contents manually, what is the best way.
I have attachment GUID value, from form i will have HttpPostedFile object.
This update should not add any extra attachment but should update the existing one and attachmenthistory should have both the old and new one stored in it.
This adds a new attachement that i don't want,
DocumentHelper.AddAttachment(node, fileAttachmentColumnName, path, tree);
setting attachmentInfo.AttachmentBinary to new file binary and using AttachmentInfoProvider.SetAttachmentInfo is the right way to update? please help me on this
I'd start out by looking at the Attachment API Examples and then looking at the DocumentHelper.GetAttachment() method to get your attachment by a GUID.
Using the SetAttachmentInfo() method will take the object you pass to it and either insert or update the object. It's smart enough to do either and I'd suggest using that method vs. the Update() method.
Thanks Brendon for your response.
Please let me know how to get AttachmentBinary from HttpPostedFile. Is there any kentico method to get it? asking a silly question but I am very new to kentico
Please, sign in to be able to submit a new answer.