
I try to use
<telerik:RadFileExplorer ID="RadFileExplorer1" Runat="server" EnableEmbeddedSkins="True"InitialPath="\\network\EL00394132">
<Configuration ViewPaths="\\network\EL00394132"
DeletePaths="\\network\EL00394132"
UploadPaths="\\network\EL00394132" SearchPatterns="*.*"/>
</telerik:RadFileExplorer>
access a network shared folder by creating my own FileBrowserContentProvider
this.RadFileExplorer1.Configuration.ContentProviderTypeName = typeof(Extensions.NetworkShareProvider).AssemblyQualifiedName;It can view files
But when I try to upload a file
After click Upload button, it triggers my own FileBrowserContentProvider class
but no files are being uploaded, then get an error
it dose not trigger
How to fix? Please help !
4 Answers, 1 is accepted
Hi Dongwei,
The issue you're encountering with file uploads in RadFileExplorer, when using a network shared folder, likely relates to permission and path handling in your custom FileBrowserContentProvider. Here are a few troubleshooting steps and suggestions to address the problem:
- Check Network Permissions:
Ensure that the application has proper write permissions to the network share. TheCheckWritePermissions
method you've implemented always returnstrue
, which means you are bypassing the actual permission check. However, this may hide potential permission issues.
Try this instead:Make sure the user account under which the web application is running has both read and write permissions on the network share.public override bool CheckWritePermissions(string folderPath) { try { string testFile = Path.Combine(folderPath, "test.txt"); using (FileStream fs = File.Create(testFile, 1, FileOptions.DeleteOnClose)) { return true; } } catch { return false; } }
- Path Issues in
GetFile
Method:
In yourGetFile
method, you're combining theurl
usingPath.Combine
. If theurl
is a full UNC path (i.e.,\\network\...
), then combining it with other parts might cause issues, leading to incorrect paths.
Instead ofPath.Combine
, try using theurl
directly:public override Stream GetFile(string url) { return new FileStream(url, FileMode.Open, FileAccess.Read); }
- Check the Upload Process:
The upload process may not be completing successfully, or the file path may not be handled correctly. In yourStoreFile
method, theSaveAs
operation could be failing silently if the path is not valid. Here are a few things to check:- Ensure that the full path being generated is correct. You can add logging to see what
fullPath
is being generated:
`public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments) { string fullPath = Path.Combine(path, name); // Log fullPath or debug here file.SaveAs(fullPath); return fullPath; }
- Make sure the
file.SaveAs(fullPath)
is not silently failing. You can wrap it in a try-catch block to handle and log any exceptions.
- Ensure that the full path being generated is correct. You can add logging to see what
- IIS Configuration:
If you're hosting this application on IIS, make sure that:- The application pool identity has the necessary permissions on the network share.
- The file size limits in IIS are not preventing the upload (check the
maxAllowedContentLength
andmaxRequestLength
settings in the web.config).
- Test the Sample
PhysicalpathFilesystemProvider
Application:
I recommend testing the sample PhysicalpathFilesystemProvider application provided in the following KB article: FileExplorer-PhysicalpathFilesystemProvider.zip.
It is important to examine how the path mappings are done inside theApp_Code\MappingFile.mapping
file:<?xml version="1.0" encoding="utf-8" ?> <CustomFileBrowserProvider> <Paths> <genericHandlerPath>FileSystemHandler.ashx</genericHandlerPath> </Paths> <Mappings> <Mapping> <PhysicalPath> <![CDATA[C:\PhysicalSource\ROOT]]> </PhysicalPath> <VirtualPath><![CDATA[MyCusomRootDir 1/]]></VirtualPath> </Mapping> <Mapping> <PhysicalPath> <![CDATA[\\Telerik.com\Path\SharedDir]]> </PhysicalPath> <VirtualPath><![CDATA[MySharedRootDir/]]></VirtualPath> </Mapping> </Mappings> </CustomFileBrowserProvider>
Regards,
Rumen
Progress TelerikStay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Hi Rumen,
Thanks for your help!
1. I checked, I do have write permission:
2. I checked web.config, I do have maxAllowedContentLength
and maxRequestLength
settings. if I switch to virtual folder with default provider, upload files works fine.
3. After I click the upload button in the upload file popup. Should I expect a "saving file" event to be triggered, likely using the StoreFile() method, however, it is never being triggered, but the GetFile() method is being called.
4. How to run and debug your sample code PhysicalpathFilesystemProvider?
Thank you for your time and assistance
Hi Dongwei,
Thank you for the additional information!
Permissions and Web.config Settings
- It's good to hear that you have confirmed the write permissions and the necessary web.config settings. Since the upload works with the default provider in a virtual folder, the issue might be related to the custom
FileBrowserContentProvider
.
Upload Button and StoreFile Method
- After clicking the upload button, the
StoreFile()
method should be triggered to handle the file saving process. IfStoreFile()
is not being called andGetFile()
is being called instead, it suggests that the upload process might not be reaching the storage phase correctly.
Debugging the Custom Provider
- Ensure that the custom provider is correctly set up and that all necessary methods are overridden. Here is a quick checklist and a code snippet to verify your setup:
public class CustomFileBrowserContentProvider : FileBrowserContentProvider
{
// Constructor
public CustomFileBrowserContentProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths)
: base(context, searchPatterns, viewPaths, uploadPaths, deletePaths) { }
public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments)
{
string fullPath = Path.Combine(path, name);
file.SaveAs(fullPath);
return fullPath;
}
public override Stream GetFile(string url)
{
return new FileStream(url, FileMode.Open, FileAccess.Read);
}
// Other necessary overrides...
}
Running and Debugging PhysicalpathFilesystemProvider
To run and debug the PhysicalpathFilesystemProvider
sample code, follow these steps:
Download and Extract:
- Download the sample code from the provided link and extract it to your local machine.
Open in Visual Studio:
- Open the solution file (.sln) in Visual Studio.
Set Up IIS or IIS Express:
- Ensure that the project is configured to use IIS or IIS Express with the correct application pool identity having the necessary permissions to access the network share.
Configure Paths:
- Update the
MappingFile.mapping
file with the correct paths to your network share and ensure the paths are correctly mapped.
- Update the
Debugging:
- Set breakpoints in the custom provider's methods (e.g.,
StoreFile
,GetFile
) and run the project in debug mode. - Perform the upload operation and check if the breakpoints are hit, allowing you to step through the code and identify any issues.
- Set breakpoints in the custom provider's methods (e.g.,
Here is a sample MappingFile.mapping
configuration:
<?xml version="1.0" encoding="utf-8" ?>
<CustomFileBrowserProvider>
<Paths>
<genericHandlerPath>FileSystemHandler.ashx</genericHandlerPath>
</Paths>
<Mappings>
<Mapping>
<PhysicalPath><![CDATA[\\network\EL00394132]]></PhysicalPath>
<VirtualPath><![CDATA[MySharedRootDir/]]></VirtualPath>
</Mapping>
</Mappings>
</CustomFileBrowserProvider>
Ensure that the paths are correctly mapped and accessible by the application.
If you continue to experience issues, please provide more details or any specific error messages you encounter during debugging.
Please refer to the following articles for additional information:
- https://docs.telerik.com/devtools/aspnet-ajax/controls/editor/functionality/dialogs/examples/custom-filebrowsercontentprovider
- https://docs.telerik.com/devtools/aspnet-ajax/controls/fileexplorer/server-side-programming/use-custom-filebrowsercontentprovider
Regards,
Rumen
Progress Telerik
one more thing. the layout in the upload pop appears to be incorrect. how to fix?
I set my RadFileExploer use EnableEmbeddedSkins
<telerik:RadFileExplorer ID="RadFileExplorer1" Runat="server" EnableEmbeddedSkins="True" width="100%" FileExplorerMode="FileSystem">
I am glad that the FileBrowserContentProvider issue is resolved!
To address the layout issues in the upload popup, please consider the following steps:
RenderMode="Lightweight" - the Classic rendering is obsolete since 2015 and it is a good idea to switch to Lightweight, which could resolve the issue.
Check for Conflicting Styles: Ensure that there are no conflicting styles in your application that might be affecting the layout of the upload popup. You can inspect the applied styles to the dialog via the browser DevTools Style Inspector. See this blog post for more information: See the Applied Styles.
- Custom CSS Adjustments: If the embedded classic skins are not rendering correctly, you might need to add custom CSS to adjust the layout. You can do this by overriding specific CSS classes used by the dialog and import them through the DialogsCssFile property.
Best Regards,
Rumen
Progress Telerik
I changed to
<telerik:RadFileExplorer ID="RadFileExplorer1" EnableEmbeddedSkins="true" EnableEmbeddedBaseStylesheet="true" Runat="server" width="100%" RenderMode="Lightweight">
</telerik:RadFileExplorer>
but the upload pop up still appears not quite right. How to adjust?
Hi Dongwei,
You can adjust the upload popup window with CSS, by targeting its respective classes:
.rfeUploadInfoPanel {
width: 200px;
}
html body .RadWindow .rwContent {
background-color: red;
}
To narrow down the issue, I would suggest inspecting the HTML elements and the styles applied to them. You can follow the suggestions in the first two points of the Improve Your Debugging Skills with Chrome DevTools blog post explaining how to inspect the generated HTML and check the applied styles for various elements.
Once you know the styles you need to override, you can use the same style selector and add "html body " in front of it to make it more specific, and "stronger". More on CSS specificity you can find here:
- Specifics on CSS Specificity;
- CSS Specificity: Things You Should Know;
- Specificity - CSS | MSDN;
- CSS !important: Don’t Use It. Do This Instead
To learn more about CSS styling and using the Browser's developer tools, you may find the following videos useful:
- How to Use the Chrome Inspector to Edit Your Website CSS - contains a Video
- Get Started With Viewing And Changing CSS
- Chrome Developer Tools Tutorial - Inspect and Test CSS 2019 - video
- Chrome DevTools for CSS - Better CSS Coding & CSS Debugging with Developer Tools - video
- Testing CSS Styles with Chrome Inspector Tool - video
Best Regards,
Vasko
Progress Telerik
How to make this "Drop Files Here" zone bigger?
and when I try to open a file
I'd like to be able to click on a link to an Excel file and have it open directly in Excel on my computer, without any intermediate popup windows. Is this possible? or download to local?
Hi Dongwei,
Let's keep discussions centered on the original topic. For any new requests, please create dedicated new forum posts to address them appropriately:- How to enlarge the Drop Files Here Zone in RadAsyncUpload's Upload Dialog of RadFileExplorer?
- How to Open Excel Files Directly from a Link in RadFileExplorer?
Regards,
Rumen
Progress Telerik