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

[Solved] MVC Extensions: Image Browser delete file and directory not working

2 Answers 31 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mr.Y
Top achievements
Rank 1
Mr.Y asked on 30 May 2012, 03:57 PM
Hi,

When an image is uploaded that contains a space or spaces in the name it is not possible to delete it. This is also the case for directories that are created.

I think this is because the space, in the path argument in the controller, is encoded as %20 when send to the controller.

Is there a workaround for this. Surely I won't be the fist to come across this behaviour.

Thanks in advance for any feedback.

Kind regards,
Yorrick vd Voort

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 04 Jun 2012, 11:18 AM
Hello Yorrick vd Voort,

I reproduced the problem you wrote about and we will investigate what exactly is causing this behavior. A workaround for now is to set custom action methods which to either delete the files and folders or decode the path and call the EditorFileBrowserController methods. For example:
.FileBrowser(t => t
    .DeleteFile("DeleteEncodedFile", "ImageBrowser")
    .DeleteDirectory("DeleteEncodedDirectory", "ImageBrowser")
    .Browse("Browse", "ImageBrowser")
    .Thumbnail("Thumbnail", "ImageBrowser")
    .Upload("Upload", "ImageBrowser")
    .CreateDirectory("CreateDirectory", "ImageBrowser"))
public ActionResult DeleteEncodedFile(string path)
{
    var decodedPath = Server.UrlDecode(path);
    return DeleteFile(decodedPath);
}
 
public ActionResult DeleteEncodedDirectory(string path)
{
    var decodedPath = Server.UrlDecode(path);
    return DeleteDirectory(decodedPath);
}

Kind regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Mr.Y
Top achievements
Rank 1
answered on 06 Jun 2012, 04:22 PM
Hi,

Thanks for the reply and the solution. This helped a lot.
BTW the issue with the space is also there when you try to open a folder with a space in the name.

I used your suggestion and created a new method and returned the Browse Jsonresult like below:

 

 

 

public  JsonResult BrowseEncoded(string path)
{
    var decodedPath = Server.UrlDecode(path);
    return Browse(decodedPath);
}

Regards,
Yorrick

 

Tags
General Discussions
Asked by
Mr.Y
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Mr.Y
Top achievements
Rank 1
Share this question
or