API Questions on Kentico API.
Version 6.x > API > File Upload View modes: 
User avatar
Member
Member
positivepurchasing - 9/5/2012 4:02:43 AM
   
File Upload
Hi

I have created a document type with a file field. Looking in the custom table in the database I see a guid.

Can anyone give some info on how to get the file (and path) or point me to some documentation. So I can display the file on a web page.

Thanks
Paul.

User avatar
Member
Member
positivepurchasing - 9/5/2012 4:32:35 AM
   
RE:File Upload
Hi

Looking in the 'CMS_Attachment' table I noticed the guid and file I uploaded earlier.

According to this http://devnet.kentico.com/docs/devguide/index.html?database_table_api.htm there should be an AttachmentProvider class to load the attachment row but there is not.

PLEASE can someone help me.


Cheers
Paul

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 9/5/2012 4:43:45 AM
   
RE:File Upload
Linking attachments

Detailed description:
If you need to create a permanent link to a file uploaded as a document attachment, you need to use a URL in the following format:

http://www.example.com/getattachment/763c8921-be94-4610-99b4-25e8d3be5b08/logo.aspx

The URL consists of the following parts:
<domain>/getattachment/<file GUID>/<filename><extension>

The <file GUID> value is not the same as the document GUID. It's a GUID of the file in the CMS_Attachment table. You can find this GUID if you display the attachment in CMS Desk and view its URL

The <file name> value can contain any text.

You can find more details on available parameters in the following topic: GetFile.aspx parameters

Best regards,
Martin Danko

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 9/5/2012 4:37:35 AM
   
RE:File Upload
Hi Paul,

You can find helpful the following articles:
Kentico DevGuide - Where the files are stored
Kentico DevGuide - Files related settings
Kentico DevGuide - Using media gallery web part

Best regards,
Martin Danko

User avatar
Member
Member
positivepurchasing - 9/5/2012 6:58:23 AM
   
RE:File Upload
Hi Martin

I've used the information you posted to create the 'getattachment' string. I just queried the db directly to retrieve the attachment filename.

Many thanks for your posts and help.

Cheers
Paul

User avatar
Member
Member
positivepurchasing - 9/5/2012 7:37:09 AM
   
RE:File Upload
Hi

One other thing it seems that sometimes you need to add .aspx to the end of the url.

Why is something so simple so over complicated?

Cheers
Paul

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 9/5/2012 7:59:40 AM
   
RE:File Upload
It's probably due because you haven't uploaded the files using Media Library.

Best regards,
Martin Danko