Get Image Attachment while using Versioning

James Mosquito asked on August 31, 2021 16:28

Hi we are using Kentico 12.0.93 with Versioning without workflow and Object versioning enabled in settings.

When adding images to an attachment field type by code the image is being added to [CMS_AttachmentHistory] but not to [CMS_Attachment].

I can retrieve the images for the published version of the current document by using the AttachmentHistoryInfoProvider. However all of the urls retrieved using the AttachmentURLProvider are throwing 404 errors.

Example Urls: AttachmentURLProvider.GetAttachmentUrl(attachmentHistoryInfo.AttachmentGUID, attachmentHistoryInfo.AttachmentName) http://domain.tld/getattachment/3b974257-8ce0-48f8-8352-0562957f06ec/example-image.jpg

AttachmentURLProvider.GetPermanentAttachmentUrl(attachmentHistoryInfo.AttachmentGUID, attachmentHistoryInfo.AttachmentName) http://domain.tld/getfile/3b974257-8ce0-48f8-8352-0562957f06ec/example-image.jpg

VirtualPathUtility.ToAbsolute(AttachmentURLProvider.GetFilePhysicalUrl(SiteContext.CurrentSiteName, attachmentHistoryInfo.AttachmentGUID.ToString(), attachmentHistoryInfo.AttachmentExtension)) http://domain.tld/GetAttachment/SiteName/files/3b/3b974257-8ce0-48f8-8352-0562957f06ec.jpg

is it possible to link directly to AttachmentHistory objects? Or do I need to approach this a completely different way?

   Please, sign in to be able to submit a new answer.