Menu

Unable to upload file

Help
Gabriel
2010-06-14
2013-05-13
  • Gabriel

    Gabriel - 2010-06-14

    I'm working on the English Wikipedia and Wikimedia Commons.

    This is roughly my code.

    string siteurl = "http://commons.wikipedia.org";
    Site wikiSite = new Site(siteurl, name, pw);
    page.title = wikiSite.namespaces["6"] + ":" + fileName;
    try
                {
                    page.Load();
                }
                catch(Exception ex)
                {
                    return false;
                }
                if (page.Exists())
                {
                    return false;
                }
                try
                {
                    page.UploadImage(filepath, "mydesc", "license", "copystatus", "sourceurl");
                }
                catch (Exception ex)
                {}
    

    My filepath is something like this ""C:\\Documents\\Some Files\\image321abc.jpg" . That should still work, right?

    Here's the exception that comes up.
    {"The remote server returned an error: (503) Server Unavailable."}

       at DotNetWikiBot.Site.GetMediaWikiMessagesEx(Boolean forceLoad)
       at DotNetWikiBot.Page.UploadImage(String filePathName, String description, String license, String copyStatus, String source)

    I also noticed this on the Mediawiki page that the login has changed. I'm not sure if this affects DotNetWikiBot.
    http://www.mediawiki.org/wiki/API:Client_code
    https://bugzilla.wikimedia.org/show_bug.cgi?id=23076

    Thanks,
    Gabriel

     
  • Gabriel

    Gabriel - 2010-06-14

    There's a typo up above. Instead of commons.wikipedia.org, it should be commons.wikimedia.org  . This is not the problem since it's still not working on either http://en.wikipedia.org  or  http://commons.wikimedia.org

    Also, to be clear, the exception is caught during the page.UploadImage call.

     
  • Gabriel

    Gabriel - 2010-06-15

    Ok, here's an update.

    Even though an exception is being thrown, the file is still being uploaded. The exact location where it's being thrown is in the GetMediaWikiMessagesEx(bool forceLoad) method and the exact line is

    doc.LoadXml(File.ReadAllText(filePathName, Encoding.UTF8));

    I can confirm that filePathName contains the file with the html markup.

    I've been doing my testing on vgsales.wikia.com, but I'm also getting the exception on Wikimedia Commons.

    I'm using ASP.NET 4.0, C#

    StackTrace

    2010-06-15 10:43:05,895 [20] ERROR [(null)] - The remote server returned an error: (503) Server Unavailable.
       at System.Net.HttpWebRequest.GetResponse()
       at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
       at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
       at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
       at System.Xml.XmlTextReaderImpl.OpenAndPush(Uri uri)
       at System.Xml.XmlTextReaderImpl.PushExternalEntityOrSubset(String publicId, String systemId, String baseUriStr, Uri& baseUri, String entityName)
       at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset(String systemId, String publicId)
       at System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter.PushExternalSubset(String systemId, String publicId)
       at System.Xml.DtdParser.ParseExternalSubset()
       at System.Xml.DtdParser.ParseInDocumentDtd(Boolean saveInternalSubset)
       at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
       at System.Xml.DtdParser.System.Xml.IDtdParser.ParseInternalDtd(IDtdParserAdapter adapter, Boolean saveInternalSubset)
       at System.Xml.XmlTextReaderImpl.ParseDtd()
       at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
       at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
       at System.Xml.XmlTextReaderImpl.Read()
       at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
       at System.Xml.XmlDocument.Load(XmlReader reader)
       at System.Xml.XmlDocument.LoadXml(String xml)
       at DotNetWikiBot.Site.GetMediaWikiMessagesEx(Boolean forceLoad)
    
     
  • CodeDriller

    CodeDriller - 2010-07-03

    More stable solution was introduced in version 2.94.

     
  • Gabriel

    Gabriel - 2010-07-03

    Thank you.

    I deployed my app on a shared hosting webserver and I'm not receiving this error.

    Access to the path 'Cache' is denied.

    Access to the path 'Cache' is denied.   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj)
       at System.IO.Directory.CreateDirectory(String path)
       at DotNetWikiBot.Site.GetPaths() in C:\Users\w3stfa11\Documents\Visual Studio 2010\Projects\video-to-wikipedia.git\Video-to-Wikipedia\Models\DotNetWikiBot.cs:line 340
       at DotNetWikiBot.Site.Initialize() in C:\Users\w3stfa11\Documents\Visual Studio 2010\Projects\video-to-wikipedia.git\Video-to-Wikipedia\Models\DotNetWikiBot.cs:line 242
       at DotNetWikiBot.Site..ctor(String site, String userName, String userPass, String userDomain) in C:\Users\w3stfa11\Documents\Visual Studio 2010\Projects\video-to-wikipedia.git\Video-to-Wikipedia\Models\DotNetWikiBot.cs:line 198
       at DotNetWikiBot.Site..ctor(String site, String userName, String userPass) in C:\Users\w3stfa11\Documents\Visual Studio 2010\Projects\video-to-wikipedia.git\Video-to-Wikipedia\Models\DotNetWikiBot.cs:line 181
       at Video_to_Wikipedia.Models.VideoDownloader.UploadFile(String fileToUpload) in C:\Users\w3stfa11\Documents\Visual Studio 2010\Projects\video-to-wikipedia.git\Video-to-Wikipedia\Models\VideoDownloader.cs:line 122
    System.Collections.ListDictionaryInternal
    
     

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.