Update
The issue is fixed and the SE Uploader works for me on Mathematica version 12.1 and 11. This was only possible because Lukas provided everything necessary and I only had to convert it to Java. A big thanks for that!
The current version is 131 and you can try the "Update" button or simply use
Import["https://raw.githubusercontent.com/halirutan/Mathematica-SE-Tools/master/SETools/Installer.m"]
There are, however, some important things to note:
Due to https
, Java needs to use TLSv1.x which unfortunately wasn't introduced until Java 7. Mathematica 9 uses Java 1.6, Mathematica 10.4 uses Java 1.7.0_13. In both versions, I get an IO error because the TLS version is not supported. That means I cannot even make a simple request to get the StackExchange page code. The issue came up in this SO post, but I have to admit I'm far out of my comfort zone here. Although there seems to be a way to use additional libraries to make it work, it'd take me a lot of reading to understand everything.
For uploading cells or notebooks, I had to fix the Hash
issue (hopefully once and for all). When you upload an expression encoded in an image, I add a small consistency hash but since Hash[{1,2,3},"MD5"]
gives different results in Mathematica 10 and 11, this never worked well. I fixed this now but it also means that you get a warning with every uploaded code from before. You can wrap AbortProtect[...]
around everything to make it work. It wasn't supposed to be a security measure anyway.
In 2019, the upload time for images increased. I talked to Szabolcs about this back then, but now I know that it's not the uploader. I verified that even a tiny image takes a long time when uploaded purely within Java. That means SE added a delay or some other measure. It's annoying but I can assure you, it's not the uploader.
Now here are two positive things besides that the uploader works again:
- I stripped all meta-information, but more importantly, the palette cannot save itself anymore. That means you won't get these stupid warnings about "the palette was changed in another program" or "the palette was used in a newer version", when you use it with different Mathematica versions.
- The uploader will have the correct size in version 12 which it didn't on my system. Buttons are all visible. I hope it works for everyone.
Original
Confirmed. StackExchange did something to its network that won't let us upload images as we did before.
I investigated a bit, and I believe things have changed drastically. The relevant JS code for uploading is here and after pretty-printing it, the important stuff happens here

This means when you click on the upload image button in an SE post, a dialog opens. There you can choose an image file and when you then press "Add image", this portion is called.
To all the web-devs among us, I have the following question:
Can we imitate this? In particular, what is the fkey
that is appended in line number 2341? Our current implementation of sending PNG bytes to SE is only 20 lines of Java code.
If we want to fix this, I need some help with debugging this JS code. If you believe you can help, just edit this answer, make a line below, add your name and write down the solution :)
In case we are not able to fix this, all I can say to our Uploader is: It's been a delight you were around for so long and you brought true sunlight into our hearts. You will be dearly missed.
Added by @LukasLang
The fkey
is apparently some kind of XSRF protection. But it looks like it's easy to get one - an example Mathematica implementation looks like this:
StringCases["fkey: '" ~~ Shortest@fkey__ ~~ "'" :> fkey]@
Import["https://stackexchange.com", "Source"]
And with the following, we can actually upload an image:
fkey =
First@StringCases["fkey: '" ~~ Shortest@fkey__ ~~ "'" :> fkey]@
Import["https://stackexchange.com", "Source"]
(* "390e967caf1c8023d41975cced0b9e3049b5e297a3fa41ac418d7269ad750f9a" *)
image = FindFile["ExampleData/Ocelot.jpg"];
result = URLRead[HTTPRequest[
"https://stackoverflow.com/upload/image?method=json&https=true",
<|
Method -> "POST",
"Body" -> <|
"file" -> File@image,
"fkey" -> fkey
|>,
"Expect" -> "",
"ContentType" -> "multipart/form-data"
|>
],
"Body"
]
(* "{\"Success\":true,\"Error\":0,\"UploadedImage\":\"https://i.\stack.imgur.com/zfLEC.jpg\"}" *)
Import@<|ImportString[result, "JSON"]|>["UploadedImage"]
