Select the search type
  • Site
  • Web
Search
You are here:  Support/Forums
Support

Bring2mind Forums

Add a file to root programatically
Last Post 09/01/2010 12:37 PM by Peter Donker. 8 Replies.
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
ryan
New Member
New Member
Posts:5


--
08/18/2010 9:07 PM

I am looking to add files programatically, I can get it working while I create collections(folders) and then add the files to the collections(folders).  I have tried adding the files via EntriesController.SimplifiedUpload passing in both 0 and -1 as the collection id, I have also tried using EntriesController.UploadEntry however using any of these methods I receive an Object not found exception.  Is there a way to do this? What is the way to do it?

Thanks,
Ryan

Peter Donker
Veteran Member
Veteran Member
Posts:4536


--
08/19/2010 3:52 PM
Hi Ryan,

Please use an existing folder's EntryId (i.e. not -1 or 0) as CollectionID.

Peter
ryan
New Member
New Member
Posts:5


--
08/19/2010 4:06 PM
Will that not add it to that collection/folder then? I want to add the file to the root, if I use the CollectionID of an existing folder it will at the file under that folder, no? What is the CollectionID for the root? Is there a way to get the root folder? When I use EntriesController.GetRootEntry(portalId) the returned entity has an entry id of -1.
ryan
New Member
New Member
Posts:5


--
08/19/2010 4:13 PM

Note, this can be done through the UI, I just can not figure out how to do it programmatically using the EntriesController.

Peter Donker
Veteran Member
Veteran Member
Posts:4536


--
08/19/2010 4:30 PM
Hi Ryan,

No. Adding to the Root is not supported through SimplifiedUpload. It has to do with permissions inheritance.

Peter
ryan
New Member
New Member
Posts:5


--
08/19/2010 4:59 PM
How would one go about doing it then?
Peter Donker
Veteran Member
Veteran Member
Posts:4536


--
08/25/2010 3:10 PM
The root was never meant to be used as a main storage point. It has always been intended to be used for creating the first layer of subfolders specific to your application. Files would eventually be added to those folders.

To add a file to folder 0 you need to manually create it and do the uploading. So
1. Create an EntryInfo
2. Set CollectionId, PortalId, EntryType, Author, TitleML (not Title), Version (1), Owner, IsApproved, MD5Hash, FileSize, OriginalFilename, Permissions
3. Call StorageProvider.Instance().StoreFile with the entry and file to store. This will fill the fields Entry and StorageProviderID
4. Call EntriesController.AddEntry to add the entry

Peter
ryan
New Member
New Member
Posts:5


--
08/30/2010 8:05 PM
Is there a public method used to generate the EntryType or at least query it from the extensions table?
Peter Donker
Veteran Member
Veteran Member
Posts:4536


--
09/01/2010 12:37 PM
Yes. You find it here:

Common.Globals:
Public Function GetFileType(ByVal PortalId As Integer, ByVal FileExtension As String) As String

Extension can be with or without the leading "."

Peter
You are not authorized to post a reply.