Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
7099 Lượt xem

hey.

I'm writing a my own module in odoo 11.

I want to get a file from user and save the file as a file (and not in my DB as binary or base64 cause the order of the file size is around 1 GigaBytes). so in my controller I call create method of my model (witch has a field like below):

image_file = fields.Binary(string="Your picture file", attachment=True)

but when calling it, I get a weird error which says:

TypeError: argument should be a bytes-like object or ASCII string, not 'FileStorage' - - -


it would be appreciated if you could tell me how can I save this file.

thanks.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

The binary field only accepts the binary data of the file you want to upload.

So, convert your file into binary using base64 and then pass it to the binary field.

Ảnh đại diện
Huỷ bỏ
Tác giả

the problem is I want to save my file as a file, not as binary data of my file.

Is there a way to do that ?

Câu trả lời hay nhất

Please check modules by MuK IT from there you can try to create for odoo11 but if you are using python 3, maybe you can just try it 

https://apps.odoo.com/apps/modules/12.0/muk_fields_file/

Note: I'm not the author of the module

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
14
thg 10 24
47898
2
thg 2 20
8592
0
thg 5 18
2836
6
thg 6 24
31159
2
thg 1 21
8327