canbican/wordpress-java

How i can upload media?

Closed this issue · 2 comments

I cant find solution. Please can you give me a example code?
When i try;
//---------------------------------
MediaItemUploadResult result = ws.uploadFile(
new FileInputStream(
new File("D:\Resimler\Wallpaper\example.png")), "mylogo");
System.out.println(result.getUrl());
//----------------------------------
//then output;

net.bican.wordpress.exceptions.FileUploadException
at net.bican.wordpress.Wordpress.uploadFile(Wordpress.java:1536)
at net.bican.wordpress.Wordpress.uploadFile(Wordpress.java:1471)
at net.bican.wordpress.Wordpress.uploadFile(Wordpress.java:1446)

FileUploadException is actually the http status 500 on the server.

https://codex.wordpress.org/XML-RPC_WordPress_API/Media#wp.uploadFile

tells nothing but it's a 'File upload failure'. I suggest checking the server side logs to investigate further.

Thanks for answer, i was change my code for use Google Drive for use, because i cannot find anything, i inspected your exception class , yes response code returned from server 500 and their document not giving any information about this