« first day (4464 days earlier)      last day (37 days later) » 

1:21 AM
@Domen Look at your post, which doesn't seem to cause the upload interface
 
 
5 hours later…
6:19 AM
@Domen Thanks for the info. It seems to be still some months until this is implemented. Let's see if anything at all works with the custom solution.
@yode I fixed the Java part and the upload works. However, the response from the server is different now. It's easier to parse since it is JSON, but this here needs to be fixed.
The parseXMLOutput is used later in line 234 to check the HTTP response string and if there is no error, it should return the URL to the image. That should be really straight-forward now using StringImport[.., "JSON"] and just checking the Success field and extracting the "UploadedImage" field.
I have the updated version in the fix_changed_api and the Java jar in SETools is recompiled and fixed.
Who is helping out?
 
6:46 AM
If you want to test the upload to see exactly how the response looks, I have added Mathematica example code to the API docs. Or you can check out this screenshot
 
7:11 AM
@halirutan If you can upload normally now, do you know how to fix the error of my code?
getFKey =
First@StringCases[
URLRead[HTTPRequest["https://stackexchange.com"]]["Body"],
"fkey: '" ~~ Shortest[fkey___] ~~ "'" :> fkey];
img = Image[RandomInteger[255, {20, 30, 3}], "Byte"];

ImportString[
URLRead[HTTPRequest[
"https://mathematica.stackexchange.com/upload/image", <|
Method -> "POST",
"Body" -> {"file" -> <|"Content" -> ExportString[img, "PNG"],
"MIMEType" -> "image/png"|>, "fkey" -> getFKey}|>],
"Body"], "RawJSON"]
I noticed that you implemented it in java, I wonder if I can upload it with MMA, because I need to use this feature in some places, and I don't know java programming
 
I don't use an fkey at all. I simply make an HTTP request to `https://stackoverflow.com/upload/image?method=json?https=true` and include the image. Even if you don't know Java, the code should be readable

https://github.com/halirutan/Mathematica-SE-Tools/blob/fix_changed_api/lib/src/main/java/de/halirutan/se/tools/SEUploader.java#L51-L62
Ah wait, I know..
 
How do you install your new branch (fix_changed_api)? The old command Import["http://goo.gl/rQtfHZ"] doesn't seem to work, does it?
@halirutan
 
7:27 AM
Just go to github.com/halirutan/Mathematica-SE-Tools/tree/fix_changed_api and click the green "Code" button and download the zip. After extracting, you should be able to follow my example in the screenshot above by adapting the paths to the jar.
 
And even I can't do this without using fkey, and it's no different from your java code, right?
img = Image[RandomInteger[255, {20, 30, 3}], "Byte"];

ImportString[
URLRead[HTTPRequest[
"https://mathematica.stackexchange.com/upload/image", <|
Method -> "POST",
"Body" -> {"file" -> <|"Content" -> ExportString[img, "PNG"],
"MIMEType" -> "image/png"|>}|>], "Body"], "RawJSON"]
 
@yode My guess is that the "Body" is not correct. Maybe "file" needs to be specified differently. In any case, I use a ToCharacterCode in my example, but you don't. This might also be a reason.
 
But I have no problem using it that way up there: chat.stackexchange.com/transcript/message/65469613#65469613
@halirutan I did just now, but it seems your new version still gets errors?
 
@yode Your URL is wrong:
 
 
7:36 AM
img = Rasterize[Image[RandomInteger[255, {20, 30, 3}], "Byte"]];

data = ToCharacterCode@ExportString[img, "PNG"];

ImportString[
 URLRead[HTTPRequest[
   "https://stackoverflow.com/upload/image?method=json?https=true", <|
    Method -> "POST",
    "Body" -> {"file" -> <|"Content" -> data,
        "MIMEType" -> "image/png"|>}|>], "Body"], "RawJSON"]
@yode Please read my first message again. The Java upload functionality works, but there is still some work to be done in the Mathematica code that uses the function and parses the HTTP response.
 
@halirutan Ok, the MMA code is working fine after I used your url, but can you tell me where you got your url from? My browser developer tool has detected that my url is correct
@halirutan Sorry, my English ability doesn't work very well sometimes
 
@yode I really don't know anymore. The SE Uploader code is more than 10 years old. I guess at some point Szabolcs or someone else found the right URL and we just used it.
 
@halirutan Well, it seems that you use is stackoverflow interface, and mathematica. Stackexchange page does not. As for behind parameter ?method=json?https=true seems to be omitted
Do you not often use MMA now? I see you've replaced the old "golden hammer"(as you call it). :)
 
 
1 hour later…
9:04 AM
@yode I use Mathematica primarily for my own stuff. But everything I do in collaboration with colleagues is usually in a programming language that is free.
 
 
11 hours later…
7:42 PM
interesting ad I saw
 

« first day (4464 days earlier)      last day (37 days later) »