I am uploading an image file:
oFReader.readAsDataURL(fileObject);
oFReader.onload = function(oFREvent){
var picture = oFReader.result;
(... continue)
And, ajaxing:
var dataDict = {'purpose':'newpicture', 'picture':picture};
$.ajax({
type:'POST',
url:'https://mydomain.whatever',
data:JSON.stringify(dataDict)
})
When I print out 'picture' variable, it is like:
"data:image/jpeg;base64,/9j/4AAQSk...
Now, I am getting a new error on my AWS with Python 3.5, which did not occur on my local with Python 3.6. On line:
import json
if(request.body):
data = json.loads(request.body)
I am getting the error:
TypeError: the JSON object must be str, not 'bytes'
I am guessing that it is because json.loads changed:
Changed in version 3.6: s can now be of type bytes or bytearray. The input encoding should be UTF-8, UTF-16 or UTF-32.
But, I thought that I was turning the image into base64 string. What am I sending? String or Bytes? How do I send this image as an string??