-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question related to the preview/path and possible improvements #18
Comments
Hi, lets try to be consistent.
Do you suggest to replace them as at your code snippet? Again, I need to understand you case in details.
|
1Yes, I wrote a connector for JAVA running with the Spring MVC framework ( /!\ Your hyperlink on the word MVC leads to a connector in Microsoft .NET MVC language). In the current repo, you have a JSP connector (JAVA) but it doesn't work. 2I use the filemanager for manage files on the server and to select an image in the WYSIWYG editor (tinymce). Nothing special. I will take your example with the getinfo API response to explain my case.
So the file is /audio.mp3. In java, we usually upload the file on an external folder outside the app, in my app this file will be stored for example in this folder : **/srv/webdata/appName/upload/**audio.mp3 But you can’t access to this path directly in the browser, you must pass through a controller; for example, to view this file we need to go in this address : http://www.site.com/public/audio.mp3 Short summary :
In the getinfo API response, we have 2 main data : Path & Preview In my connector, I use
Does my use of field preview is correct? (If the usage of preview is correct, there is no problem, I tell you that for information purposes.) 3Yes, it was the getinfo API response. My API response is the same as the php connector. In my app, as I use a controller to browse the file, so for the audio.mp3 example, my API response will be :
As the preview path is relative to the filemanager path, I must set : "../../../public/audio.mp3" to lead to http://www.site.com/public/audio.mp3 ) It's bit ugly but It’s working well. So (if all works well) why I asked to add 2 new parameters.a) for the select function (in WYSIWYG) and COPY function.(This point is independent of my case) If the preview field is the correct path to view the file in the browser. When you copy the path into the clipboard or select an image in the WYSIWYG editor, you should have the preview's value (and not the path). See this screenshot (I took your audio.mp3 file for the example) I think this issue is related to the same problem b) absolute path for previewBecause in my case, the preview path should not depend on to the file manager path. ( or maybe sometimes, we would like to serve heavy files in a external website). I've seen a possible solution in the S3Filemanager.php, instead of serve the file directly, use the GET param mode=readfile for the preview :
but that implies to pass through a controller to serve the file, this will be bad for performance if you planned to serve static files through a reverse proxy like Nginx. Now , maybe I miss a settings or misunderstood something, I hope it's more clear now. |
Thank you for the detailed explanation. I have got your case now and decided to check PHP with the TinyMce. As I said before, I made a lot of changes, but I didn't bother to check how it works in conjunction with any of WYSIWYG editors. That is why you faced with the issue that you have fixed your PR. The same thing with the "path" and "preview" params. I have just tested FM in TinyMce and got some issues as well. I agree that an absolute path should be returned for WYSIWYG and COPY function. If I got you right all your problems can be solved in case the absolute path is treated for preview and inside WYSIWYG instead of relative one. Is that will be enough? I'm not sure because you specified your path as Anyway I am going to resolve the current problem keeping in mind your case. |
If you agree for the full path for the functions "select" and "copy", I think we should consider in the API response, "Preview" as the reference value to be used to view/select or copy/paste) a file and keep "Path" value only for server exchanges. For now in a file's detail, the file manager uses the "preview" value to view files except for images, they use the value of "Thumbnail". Images should also use "Preview" value (to keep the same logic and because in any case we need the preview value for the function "select" and "copy"). What do you think about that? Even if you/we fix the functions above, I will still have my ugly path if I don't want to pass through a controller to get the file :
I think I found an elegant solution, it will allow to add these functionalities (simply) without break the existing behaviour.
Suppose that location.origin + location.pathname = "http://mysite.com/folder/of/plugin" For the API response "getinfo", here is 4 possibility of values for "Preview" : case 1 => "/userfiles/audio.mp3"; // relative path (folder bellow fm's root)
There is no a lot of changes to do, here is the PR, It will easier to understand. |
Thank you. I will take a look this tomorrow. |
I have accepted your PR, but as I mentioned, there were some issues for specific cases. You can face it if open file in preview mode which are not supposed to be previewed. For instance *.html or *.zip. Those file types don't have appropriate viewer associated by default. In this case preview page should display placeholder icon. And there were other settings-specific cases. Anyway the idea behind your PR is good, so I have developed it and made some bugfix and modifications. You can see not "getinfo" method returns following pathes:
Also I have added new I'm going to describe all the thing in Wiki as well. Hope you will be good with my modifications. |
Yes, you are right, I forgot to test this kind of file, my bad! That's perfect, the connector can now choose the way it wants to serve files! Just a few comments
|
Thanks for your notes. |
In my opinion, the big advantage of the plugin is the simple API, it's easy to create a connector (and there are already many connectors available even is it should be updated). I think you should keep the API the more simplest as possible and avoid changes that would break connectors. So I suggest that :
become
Names are the same as before, they were good (and avoid breaking connectors). See my PR, after this, I think we are done with this issue. |
I have accepted your PR with a note and commited minor adjustments. You can close that issue if we have handled all things related to this particular issue. |
Hi, I am in the process of merging this change into PR #21. Doing this I could not get to work case 2) which is what I have to to
The code in current filemanager.js is different, as createPreviewUrl merges baseUrl and normalized path, so location.pathName would NOT be normalized as it is already in baseUrl. Possible solution OK: BUT there is another bug: An absolute URL, e.g. In the original code it´s ok, as the scheme is preserved. |
I was unable to test this case like I said in PR #20, I don't understand well the purpose of the "baseUrl" parameter. If you can give me some explanations and a use case, I can maybe help to solve this. |
baseUrl is an absolute url by default (location.origin + location.pathname), as you said in your comment and occasionally the connector part is provided for the thumbnail, which should be appended. This should give you case 2. Sorry, the better reason is a relative preview provided by configuration, i.e. a ressource which is relative to the webapp, and it´s path may contain "..". |
Yeah, I have also noticed that |
Hi, I am writing a connector for java (spring MVC). I tried the JSP connector in the repo but it's not working. (I discovered later the C5 connector but I have not tried).
To create the connector, I watched the Ajax call and response, to try to understand.
My app doesn’t serve the files directly to the client, I have 2 path :
(When you try to listen a song or watch a doc the manager use the preview path (and thumbnail for images), so I think it’s the good behaviour, I am right?
The response look like this
The connector work well but I have 2 behaviour I would like to change (but maybe i miss something):
Do you agree if I add a pull request to add a boolean in the config file to choose that something like "usePreviewForSelectionAndCopy = false" ?
Same, do you agree if I add pull request to add a boolean in the config to choose if the preview path should be relative to the manager or absolute: something like « absoluteUrlForPreview = false »?
The text was updated successfully, but these errors were encountered: