title: How can I resize image with PIL on upload and serve them with flask-cloudy?
body: <p>My current solution does't works as expected. I need to get image from <code>formdata</code>, resize it and upload to local file server using flask-cloudy. How can I transform <code>_io.BufferedWriter</code> back to file object? </p>
  
  <p>And source code: </p>
  
  <pre><code>def image_add():
      if request.method == 'POST':
          if 'username' in session:
              file = request.files['image']
              print(file, file=sys.stderr)
              uploadId=str(uuid.uuid4())
              source = storage.upload(file, name=uploadId, extension=["jpeg","jpg","png"], overwrite=False, public=True)
              image_request_result = requests.get(source.full_url)
              image = Image.open(io.BytesIO(image_request_result.content))
              width, height = image.size
              max_size = [200, 200]
              image_io = io.BytesIO()
              image.save(image_io, format='JPEG')
              with open('%s_%s.jpeg' % (uploadId, '200x200'), 'wb') as file_output:
                  print(file_output, file=sys.stderr)
                  source0 = storage.upload(file_output, name=uploadId, extension=["jpeg","jpg","png"], overwrite=False, public=True)
                  print(source0, file=sys.stderr)
              resp = json.dumps({
                  "id": uploadId,
                  "url": source.url,
                  "full_url": source.full_url
              })
              return Response(resp, status=201, mimetype='application/json')
          else:
              return Response("Not authorized", status=401, mimetype='application/json')
      else:
          return Response("{request.method} is not allowed!", status=400, mimetype='application/json')
  </code></pre>
  
  <p>Thanks!</p>