This is a migrated thread and some comments may be shown as answers.

How to fix the max length of file name

7 Answers 88 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
M Kumar
Top achievements
Rank 1
Iron
Veteran
M Kumar asked on 13 Mar 2019, 03:32 AM

hi

      I have file name like this "2019 03 04 101905_RE  Indonesia   Possible opposition against the trademark application no 2019 03 04 101 D002014017706  AVATARA in the name of IGB GANGGA D002014017706  AV111111111112019 03 04 101905_RE  Indonesia   Possi.pdf"

 

when i try to upload that file name in AsyncUpload control it through the error like this below screen shot.

7 Answers, 1 is accepted

Sort by
0
HMPSOLBB
Top achievements
Rank 1
answered on 13 Mar 2019, 03:35 PM

Hi,

same problem for me. Drag'n'Drop an email out of outlook to the desktop will create a file name using the email subject and adding .msg. I need a possibility to change the filename before or while uploading (not after because you cannot save these lang filename in the upload folder because of the 255 chars restriction. Anyone any idea to handle this???

 

Best

Oliver

0
M Kumar
Top achievements
Rank 1
Iron
Veteran
answered on 14 Mar 2019, 06:37 AM
Hi,
    Any client side function to validate file name if more than 255 ? in telerik demo upload page also got same problem, but not have any error msg popup to end user.
screenshot : http://prntscr.com/mxmzzk
                    http://prntscr.com/mxn0jx

Pls reply asap
0
HMPSOLBB
Top achievements
Rank 1
answered on 14 Mar 2019, 07:32 AM

We are currently testing this:

https://docs.telerik.com/devtools/aspnet-ajax/controls/asyncupload/how-to/how-to-extend-the-radasyncupload-handler

Looks very promising for me at the moment

 

best

Oliver

0
HMPSOLBB
Top achievements
Rank 1
answered on 14 Mar 2019, 08:44 AM

The error occurs in this method: 

Telerik.Web.UI.AsyncUpload.ContentAppender.AppendToFile(String fullPath, Stream content, Int32 retries)  --> System.IO.PathTooLongException

 

This might be a problem of the used .Net Framework, have a look at the following MS page:

https://docs.microsoft.com/de-de/dotnet/api/system.io.pathtoolongexception?view=netframework-4.7.2

 

0
Eyup
Telerik team
answered on 19 Mar 2019, 01:53 PM
Hi Guys,

I'm glad you've found out some directions to resolve this issue. If the problem remains I suggest that you open a formal support ticket and send us a working sample so we can assist you more precisely. This will allow us to further research the scenario and provide appropriate details based on the case.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
M Kumar
Top achievements
Rank 1
Iron
Veteran
answered on 27 Mar 2019, 10:11 AM

Hi, when upload telerik demo upload control also same problem, currently we restrict file name length upto 150, so it temporary it solved,but how if file name above 255 ? bcz when upload file name length above 255, it throw error in resource scrip , it cant handle.

http://prntscr.com/n3jytd

http://prntscr.com/n3jymq

0
HMPSOLBB
Top achievements
Rank 1
answered on 27 Mar 2019, 10:26 AM

Hi,

 

for me the only way was to create a custom HttpHandler within the RadAsyncUpload Control. I overwrite the base.ProcessRequest and handle the Chunk File handling by myself. I do not use the Telerik tmp file naming. 

public new void ProcessRequest(System.Web.HttpContext context)
        {
            try
            {
                if (AsyncUpload.IsAsyncUploadWorkaroundEnabled)
                {
                    string RawCMD = context.Request.Form[CHUNK_METADATA];
 
                    if (!string.IsNullOrWhiteSpace(RawCMD))
                    {
                        AsyncUploadChunkMetaData aucmd = JsonConvert.DeserializeObject<AsyncUploadChunkMetaData>(RawCMD);
 
                        if (aucmd.UploadID.Length > 100)
                        {
                            aucmd.UploadID = FileUtils.TruncateFileName(aucmd.UploadID, MaxFileName);
 
                            SetFormValue(context.Request.Form, CHUNK_METADATA, JsonConvert.SerializeObject(aucmd));
                        }
                    }
                }
 
                base.ProcessRequest(context);
            }
            catch (Exception ex)
            {
 
                System.Diagnostics.Debug.WriteLine(ex);
 
                throw;
            }
        }

 

private void SetFormValue(System.Collections.Specialized.NameValueCollection form, string key, string value)
{
    // Get the "IsReadOnly" protected instance property.
    var propInfo = form.GetType().GetProperty
    (
        "IsReadOnly", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic
    );
 
    // Mark the form collection as NOT "IsReadOnly"
    propInfo.SetValue(form, false, new object[] { });
 
    // Change the value of the key.
    form[key] = value;
 
    // Mark the form collection back as "IsReadOnly"    
    propInfo.SetValue(form, true, new object[] { });
}

This was (for me) the only way to fix this 16bit SYSTEM.IO problem.

 

Best

Oliver

 

Tags
AsyncUpload
Asked by
M Kumar
Top achievements
Rank 1
Iron
Veteran
Answers by
HMPSOLBB
Top achievements
Rank 1
M Kumar
Top achievements
Rank 1
Iron
Veteran
Eyup
Telerik team
Share this question
or