I am not able to perform uploads after setting up the upload, view, and initial paths in the page load of the solution. The file explorer shows the initial path and I am able to navigate folders and select files. I am using your Telerik example here . What am I missing? How can I initiate a download to the .ashx handler file identified in the MappingFile.mapping configuration file? Thanks in advance.
6 Answers, 1 is accepted
0
Jermaine
Top achievements
Rank 1
answered on 12 Mar 2014, 06:57 PM
My code can be previewed here and the html code follows:
Updated Configuration for RadFileExplorer codebehind .aspx :
Also, I have a custom ashx handler that validates file according to business data logic received from the client interface. In your example the CustomFileSystemProvider.vb file uses a StoreFile method that needs to be overrided for my custom implementation. I noticed that the file's type is received as Telerik.Web.UI.UploadedFile. Is this the only way to receive the uploaded files? How does the handler file receive the uploaded file from the provider? Or, does processing occur in one or the other? I need the capture the uploaded file in my custom ashx file for processing as HttpContext. Is the StoreFile method optional or required? Please clarify. Thanks.
01.<telerik:RadFileExplorer ID="RadFileExplorerReceive" runat="server"02. EnableOpenFile="false"03. Width="260px"04. Height="350px"05. AllowPaging="true"06. PageSize="10"07. OnClientItemSelected="OnClientItemSelected">08. <Configuration EnableAsyncUpload="true" AllowMultipleSelection="true">09. </Configuration>10. </telerik:RadFileExplorer>Updated Configuration for RadFileExplorer codebehind .aspx :
01.Public Sub Configure()02. 03. RadFileExplorer1.EnableOpenFile = False04. 05. RadFileExplorer1.DisplayUpFolderItem = True06. 07. RadFileExplorer1.AllowPaging = False08. 09. RadFileExplorer1.EnableCreateNewFolder = False10. 11. RadFileExplorer1.Upload.Enabled = True12. 13. ' Set the RadFileExplorer's maximum file size property14. RadFileExplorer1.AsyncUpload.MaxFileSize = System.Configuration.ConfigurationManager.AppSettings("maxFileSize")15. 16. ' Set postbacktrigger to the ID of the control that executes file upload processing17. 'RadFileExplorer1.AsyncUpload.PostbackTriggers = New String() {"Execute"}18. 19. RadFileExplorer1.TreePaneWidth = 10020. 21. Dim physicalPathToFile As String = ""22. Dim virtualPathToFile As String = ""23. 24. For Each mappedPath As KeyValuePair(Of String, String) In MappedPaths25. 26. If mappedPath.Key.Contains("Share") Then27. ' Build the physical path to the file ;28. physicalPathToFile = mappedPath.Value29. virtualPathToFile = mappedPath.Key30. 31. ' Break the foreach loop ;32. Exit For33. End If34. Next35. 36. Dim initialpath As String = ""37. initialpath = virtualPathToFile38. 39. ' load the paths - physical, virtual - ex."C:\PhysicalSource\ROOT", "\\server.name\Path\SharedDir"40. ' the path where the files reside on the server/share41. Dim viewPaths As String()42. viewPaths = New String() {physicalPathToFile, virtualPathToFile}43. 44. ' load the upload path, clientPath, where the user's file will be uploaded to, local fileystem on the client45. ' Replace the \ with / since the File Explorer requires virtual paths46. 'Dim uploadPaths As String() = New String() {clientPath.Replace("\", "/")}47. 48. ' Testing using Path without replacing the slashes in the path value49. Dim uploadPaths As String() = New String() {clientPath}50. 51. ' set deletepath property for the upload button to work52. 'Dim deletePaths As String() = New String() {clientPath.Replace("\", "/")}53. 54. Dim deletePaths As String() = New String() {clientPath}55. 56. RadFileExplorer1.Configuration.ViewPaths = viewPaths57. RadFileExplorer1.Configuration.UploadPaths = uploadPaths58. 59. RadFileExplorer1.Configuration.SearchPatterns = New String() {"*.*"}60. 61. RadFileExplorer1.Configuration.ContentProviderTypeName = GetType(CustomFileSystemProvider).AssemblyQualifiedName62. 63. RadFileExplorer1.InitialPath = initialpath64. ' End If65. 'End If66. 67.End SubAlso, I have a custom ashx handler that validates file according to business data logic received from the client interface. In your example the CustomFileSystemProvider.vb file uses a StoreFile method that needs to be overrided for my custom implementation. I noticed that the file's type is received as Telerik.Web.UI.UploadedFile. Is this the only way to receive the uploaded files? How does the handler file receive the uploaded file from the provider? Or, does processing occur in one or the other? I need the capture the uploaded file in my custom ashx file for processing as HttpContext. Is the StoreFile method optional or required? Please clarify. Thanks.
01.Public Overrides Function StoreFile(ByVal file As Telerik.Web.UI.UploadedFile, ByVal path As String, ByVal name As String, ByVal ParamArray arguments As String()) As String02. 03. ' Testing method on how to get HttpContext from FileExplorer and send to Upload.ashx script for processing04. 'Dim upload As New Upload05. 06. 'upload.ProcessRequest(file)07. Dim virtualPathToFile As String = Context.Server.HtmlDecode(Context.Request.QueryString("path"))08. 09. Dim physicalPath As String = Me.GetPhysicalFromVirtualPath(path)10. If physicalPath Is Nothing Then11. Return String.Empty12. End If13. 14. physicalPath = PathHelper.AddEndingSlash(physicalPath, "\"c) & name15. file.SaveAs(physicalPath)16. 17. ' Returns the path to the newly created file18. Return PathHelper.AddEndingSlash(path, "/"c) & name19.End Function0
Hello Jermaine,
The StoreFile() is an abstract class that must be overriden when creating a custom FileBrowserContentProvider, and so it must receive an UploadedFile item as a first argument. The UploadedFile contains standard information regarding the uploaded FileItem, including the stream of the currently uploaded file.
On a side note, the handler provided by us in the linked by you KB article is used only for accessing the file data when opening it. This means that the handler does not interacts with the content provider neither vice versa. You will need to make a custom request in order to pass some uploaded file related information to a generic handler and to validate it after that with a custom logic.
I would like to kindly remind you that FileExplorer is not designed to work with files from the client system. This is why such an implementation may lead to unexpected behavior and so is not supported.
Regards,
Vessy
Telerik
The StoreFile() is an abstract class that must be overriden when creating a custom FileBrowserContentProvider, and so it must receive an UploadedFile item as a first argument. The UploadedFile contains standard information regarding the uploaded FileItem, including the stream of the currently uploaded file.
On a side note, the handler provided by us in the linked by you KB article is used only for accessing the file data when opening it. This means that the handler does not interacts with the content provider neither vice versa. You will need to make a custom request in order to pass some uploaded file related information to a generic handler and to validate it after that with a custom logic.
I would like to kindly remind you that FileExplorer is not designed to work with files from the client system. This is why such an implementation may lead to unexpected behavior and so is not supported.
Regards,
Vessy
Telerik
DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.
0
Jermaine
Top achievements
Rank 1
answered on 17 Mar 2014, 04:14 PM
Thanks for the explaining. From what you have suggested, I need to override the Storefile() method and pass the UploadFile property to my custom file content provider for processing. The issue I am having is with initiating the upload. The upload button is disabled.
0
Hi Jermaine,
The upload button is set as enabled/disabled depending on the current folder's permissions. In the folder's path is amont the configured Upload paths (or is a child to any of these folders) the Upload button will be enabled. Please, note, that if the whole application does not have enough permissions to view/write a specfic folder, FileExplorer also will not be able to manipulate the items.
I would suggest you to check this troubleshooting article and modify the tests in it in order to check the permissions of the listed by you folders.
Kind regards,
Vessy
Telerik
The upload button is set as enabled/disabled depending on the current folder's permissions. In the folder's path is amont the configured Upload paths (or is a child to any of these folders) the Upload button will be enabled. Please, note, that if the whole application does not have enough permissions to view/write a specfic folder, FileExplorer also will not be able to manipulate the items.
I would suggest you to check this troubleshooting article and modify the tests in it in order to check the permissions of the listed by you folders.
Kind regards,
Vessy
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.
0
Jermaine
Top achievements
Rank 1
answered on 24 Mar 2014, 04:24 PM
I discovered the problem was caused from not defining the same path for view, upload, and the initial path properties. I uncommented the path assignment statements and assigned the same path value to each property to resolve this issue. Initially, the test was successful even though I ran the FullPermissionTest function in the Page_Load without assigning the permissions so I was stumped. But on a hunch, I assigned the properties and the Upload button was enabled.
Now that I can Upload, I see that the RadAsyncUpload is being used. I would like to manually upload files selected from my queue that is populated with files selected from client click events in the explorer since my project requires an alternative upload process. Is there a means for opting out of using the RadAsyncUpload and grabbing the httpContext.RequestFiles( "filedata") for uploading at my behest? Thanks.
Now that I can Upload, I see that the RadAsyncUpload is being used. I would like to manually upload files selected from my queue that is populated with files selected from client click events in the explorer since my project requires an alternative upload process. Is there a means for opting out of using the RadAsyncUpload and grabbing the httpContext.RequestFiles( "filedata") for uploading at my behest? Thanks.
0
Hi Jermaine,
By design RadFIleEplorer provides two options for file uploading - using RadUpload and using RadAsyncUpload. Switching between both controls can be done by configuring the RadFileExplorer's Configuration-EnableAsyncUpload property:
In non of these upload options fits your scenario, you can implement a custom command in the way described in this help article, adding the desired custom upload logic to it.
Kind regards,
Vessy
Telerik
By design RadFIleEplorer provides two options for file uploading - using RadUpload and using RadAsyncUpload. Switching between both controls can be done by configuring the RadFileExplorer's Configuration-EnableAsyncUpload property:
<telerik:RadFileExplorer ID="RadFileExplorer1" runat="server"> <Configuration ViewPaths="~/" DeletePaths="~/" UploadPaths="~/" EnableAsyncUpload="false" /></telerik:RadFileExplorer>In non of these upload options fits your scenario, you can implement a custom command in the way described in this help article, adding the desired custom upload logic to it.
Kind regards,
Vessy
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.
