linguanostra / ELFinder.Connector.NET

ELFinder Connector for .NET with support for NancyFX and ASP.NET MVC
BSD 3-Clause "New" or "Revised" License
12 stars 8 forks source link

ASP.NET connector - thumbnails are not generated #2

Closed Ruslan878 closed 8 years ago

Ruslan878 commented 8 years ago

Hello everyone! I installed ELFinder.Connector.NET from Nuget into my project. I've got a problem - the thumbnails are not generated. I built ELFinder.WebServer.ASPNet project - there are not any problem. Where is can I check the generation of images in the code? Are there any ideas on this? Thanks.

linguanostra commented 8 years ago

Hello,

The generation of images is done with the ImageProcessor library.

Have a look at the ImagingUtils class, located in Core\ELFinder.Connector\Utils\ImagingUtils.cs . In it, you can check the CanProcessFile and GenerateThumbnail methods.

If the issue is not with this code, perhaps it's with the FileSystemRootVolume, located in Core\ELFinder.Connector\Drivers\FileSystem\Volumes\FileSystemRootVolume.cs . Have a look at the GenerateThumbnail method.

Another place you can look into is the GetThumbnail method in the FileSystemConnectorDriver class, located in Core\ELFinder.Connector\Drivers\FileSystem\FileSystemConnectorDriver.cs .

So the issue might be with the Driver, the RootVolume or the ImageProcessor library.

Add a few breakpoints in the methods I mentioned and see how it goes.

Let me know of your findings.

Regards,

Patrick

Ruslan878 commented 8 years ago

Hello, Patrick! I'm trying to integrate your solution in my MVC project. I use version 5.2.3 of MVC. I found problem in ELFinderBaseConnectorController file. Inside the DispatchCommand method fails to update the model via TryUpdateModel. TryUpdateModel method cannot parse query string like as "targets[]=v1_XGF2YXRhci5wbmc1,v1_XElNQUcwNDY4LmpwZw2". Therefore, after the operation TriUpdateModel command.Targets is empty for object of ConnectorGenerateThumbnailsCommand.

Regards,

Ruslan

linguanostra commented 8 years ago

Hi,

The ELFinder client uses a url query parameter named targets[] which is not handled properly by the default ASP.NET MVC model binder. Another issue is with boolean values, the client uses 0 for False and 1 for True.

To fix this, you can call the following in the Application_Start() of your Global.asax.cs

        ModelBinders.Binders.DefaultBinder = new ELFinderModelBinder();

Basically this custom model binder will map properly the ELFinder client url query parameters to work with the ASP.NET MVC model binder.

Once you change the default model binder with this custom one, it should work.

If you already have a custom model binder in your application, you can override the SetProperty method and use the same code as in the ELFinderModelBinder.cs file.

Let me know if it works.

Regards,

Patrick

Ruslan878 commented 8 years ago

Thank you, Patrick! My inattentiveness cost me a few hours. I really missed a single line in the Global.asax file: ModelBinders.Binders.DefaultBinder = new ELFinderModelBinder(); I'm sorry I wasted your time.

linguanostra commented 8 years ago

No worries, I'm glad you got it working with you application.

I must admit it's far from obvious to integrate into an existing solution, I've added some instructions in the sample Controllers of the demo application.

I'll do the same with the README soon.

Have a nice day!

Patrick