python - python烧瓶和pyrebase中的Seek()错误
问题描述
我是python和flask API开发的新手。我创建了一个 API,它在上传图像后通过 html 发布表单接受图像我将该图像传递给枕头库以调整大小,但是当我使用 .put() 方法将图像存储到 pyrebase 时收到 seek() 错误我的代码:
import requests
from PIL import Image
from file import ImgId
import pyrebase
import io
config={
"apiKey": "AIzaSyBvlJpkV7rcYwbx3wNEBARKvrpHMBALXuw",
"authDomain": "allinonetools.firebaseapp.com",
"databaseURL": "https://allinonetools-default-rtdb.firebaseio.com",
"projectId": "allinonetools",
"storageBucket": "allinonetools.appspot.com",
}
firebase = pyrebase.initialize_app(config)
app = Flask(__name__)
storage=firebase.storage()
@app.route('/')
def home():
return render_template('index.html')
@app.route("/size", methods=["POST"])
def process_image():
file = request.files['image']
# Read the image via file.stream
img = Image.open(file.stream)
new_image = img.resize((400, 400))
img_url=ImgId()
storage.child(img_url).put(img)
return jsonify({'msg': 'success', 'size': [new_image.width, new_image.height]})
if __name__ == "__main__":
app.run(debug=True)
This is the error
解决方案
推荐阅读
- c++ - 不属于任何类型的结构中的成员?和一个结构来保存一个单独的变量
- sql - 将 SQL 服务器查询转换为 SQLite
- .net - IdentityServer4 总是返回“错误”:“invalid_scope”
- r - 如何使用ggplot绘制R中一个变量的等式变化值
- sql - 如何在 SQL 中连接这 3 个表?
- c++ - 执行超时(12000 毫秒):有没有更好的方法来解决这个问题?
- visual-studio - 为什么 Visual Studio 突然停止程序并显示错误 #include gtkmm.h not found
- c# - 如何在 xml 文档中引用使用元组的方法
- python - Python 3.5 无法读取带有特殊字符的文件 ★
- python - 如何在预测后取消缩放数据?