Menu

Issues with UploadImage

Help
Luca Mauri
2017-07-23
2017-10-30
  • Luca Mauri

    Luca Mauri - 2017-07-23

    Hi there,
    I am writing here to get help about UploadImage function as I get several errors with it and I am not sure I am using it properly.
    The fragment of the code I use is:

    PaginaImmagine = New DotNetWikiBot.Page(MultiWiki, "ufp")
    PaginaImmagine.UploadImage("D:\Temp\ht\ufp\ufp.svg", "test1", "test2", "test3", "test4")

    Where MultiWiki is a properly initialized Site.

    Everything works fine with authentication, but when the file is being uploaded a 404 error is returned
    Investigating on this, I found out that DNWB was calling the following page to upload:
    http://www.lucamauri.net/wikitrek/index.php/wikitrek/index.php?title=Speciale:Upload
    This is wrong beacuse "Speciale" is the namespace for the IT-IT language (that wiki is configured in Italian), but "Upload" is the page in English.

    I saw in the source code that the namespace is queried at the site, while "Upload" is added literally, so I changed the language of the Wiki to EN in order for the code to call:
    http://www.lucamauri.net/wikitrek/index.php/wikitrek/index.php?title=Special:Upload

    Again, this was not working bacease the URI created has duplicated part: "wikitrek/index.php/" is written two times
    The correct URI should have been:
    http://www.lucamauri.net/wikitrek/index.php?title=Special:Upload
    So I created a redirect from the former to the latter.

    Now the connection can apparently be established correctly, but I get a generic error "Error occurred when uploading image "ufp"." and I am not sure where to investigate now.

    Can you please help with this issue?
    Thanks for any insight you might provide

    Luca

     

    Last edit: Luca Mauri 2017-08-15
  • CodeDriller

    CodeDriller - 2017-09-28

    It seems that you didn't escape the string "D:\Temp\ht\ufp\ufp.svg".

    It should be "D:\\Temp\\ht\\ufp\\ufp.svg".

     

    Last edit: CodeDriller 2017-09-28
  • Luca Mauri

    Luca Mauri - 2017-09-30

    Dear CodeDriller,
    thanks for your help, the need for escaping was not clear to me. May I suggest that you state this more clearly in the documentation page of the Page.UploadImage Method ?

    Regarding the other two issues, are there any suggestions from your side, or shall I go on with the workaround I used? I am asking because reconfiguring the wiki language anytime I need to upload an image is very impractical and the redirect should not be necessary in my opionion, and that should be fixed.

    Thanks

    Luca

     
  • CodeDriller

    CodeDriller - 2017-09-30

    Escaping backslashes concerns all the strings in C# and in most other programming languages. It is not specific to Page.UploadImage() method.

    https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/string

    You should use your workarounds for other issues until I have time to investigate them.

     
  • Luca Mauri

    Luca Mauri - 2017-09-30

    Sorry there was a misunderstanding: i am programming in VB.net not C#.net
    So unfortunately this does not work either, I still got the same problem

     
  • CodeDriller

    CodeDriller - 2017-10-30

    I'm glad that everything is all right now. Good Luck!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.