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

I have the following view and controller, and want to access the uploaded file data and other attributes (extension, size, etc), how can I do it? I couldn't find any documentation about it.

View:


    
    
    


Controller:

from odoo import http

class Claim(http.Controller):
@http.route('/example_route/', auth='public', methods=["POST"], website=True)
def claims(self, **kw):  
        file = kw["fileExample"] # file now only has the name of the file
        # I want to use the file here (send it to and api, check the size and extension)



Using Odoo 13

Thanks for the help


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
 enctype="multipart/form-data">

please add this into your form in HTML 

logo = kwargs.get('logo')
logo = base64.b64encode(logo.read())

and this 


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 24
1760
2
thg 9 23
3013
1
thg 6 23
2502
3
thg 8 25
7692
0
thg 10 21
2350