After several hours of banging my head against the wall, I finally figured out how to convert the curl call into a RestClient one (I'm using Ruby on Rails).
I think the problem you're having is that you have to pass the MIME type as the Content-Type in the request headers.
I'm using MiniMagick to figure out the MIME type of the image I'm uploading to LinkedIn. MiniMagick can also give you the binary string of the image that LinkedIn requires, so it's a win-win situation.
This is the call that finally worked:
file = MiniMagick::Image.open(FILE_PATH)
RestClient.post(UPLOAD_URL, file.to_blob, { 'Authorization': 'Bearer TOKEN', 'Content-Type': file.mime_type })
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…