wp-net / WordPressPCL

This is a portable library for consuimg the WordPress REST-API in (almost) any C# application
MIT License
337 stars 129 forks source link

Media.Create returns rest_upload_sideload_error #203

Closed acerov closed 3 years ago

acerov commented 4 years ago

Hi,

I am trying to upload jpg image, IsValidJWToken says JWT is valid but when I try to Media.Create it returns "rest_upload_sideload_error"

My code is simple: `System.IO.Stream fs = System.IO.File.OpenRead(ofd.FileName);

string stringFileName = System.IO.Path.GetFileNameWithoutExtension(ofd.FileName);

var myMediaItem = await client1.Media.Create(fs, stringFileName);`

To test if JWT authentication is working ok I tried to create a post and it works, I created a post without a problem.

Please help.

ThomasPe commented 4 years ago

the Media.Create method needs to know the file extension so it can set the correct mimeType. Or you can set the mimeType yourself with the latest update of the package.

ThomasPe commented 3 years ago

I’m closing this issue because it has been inactive for a while. Please feel free to reopen if you still encounter this issue. Thanks!