API
Version 7.x > API > Import files into a media library using REST View modes: 
User avatar
Member
Member
longin-natgas - 6/17/2013 7:26:00 AM
   
Import files into a media library using REST

I'm currently having trouble importing a file into a existing Media library via REST service. Basic functionality is working, I can query the media libaries content via Fiddler and a c# code snippet.

First thing: Which URL do I have to address for an insert - I used
http://localhost:6666/rest/media.library/3/children/media.file
to get the content of the appropriate media library, but what is the address if I want to insert something ?
Second thing: If I did understand the documentation correctly I have to encapsulate the metadata in a "data" tag and put it into the header of the post request.
Which fields of the "Media_File" XML structure are mandatory, and how to put that into the header. Hints for doing it with fiddler would be nice, but I wouldn't mind some c# code either

thanks

User avatar
Member
Member
Accepted solutionAccepted solution
kentico_davidb2 - 6/25/2013 7:22:41 AM
   
RE:Import files into a media library using REST
Hi,
you can insert media files using similar approach as below (necessary items are included). However, please note that media files are physical files within the file system (unlike attachments, which can be stored in binary form within database) and uploading such files via REST is not currently supported... So you can only insert the database item, not the physical file.

This feature is planned to be added in future versions of Kentico CMS.

POST http://localhost:6666/rest/media.file HTTP/1.1
Authorization: Basic YWRtaW5pc3RyYXRvcjo=
Host: localhost
Content-Type: text\xml
Content-Length: 337

<data>
<Media_File>
<FileName>test2</FileName>
<FileTitle>aaa</FileTitle>
<FileDescription>aaa</FileDescription>
<FileExtension>.txt</FileExtension>
<FileMimeType>text/plain</FileMimeType>
<FilePath>test2.txt</FilePath>
<FileSize>55</FileSize>
<FileLibraryID>1</FileLibraryID>
<FileSiteID>1</FileSiteID>
</Media_File>
</data>

User avatar
Member
Member
longin-natgas - 7/1/2013 12:04:32 AM
   
RE:Import files into a media library using REST
thanks, have to work around that then