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

Hi all,

It's my first request here and hope you will be nice with me :).

I would like to use the ODOO API in version 16.

I'm developping in JAVA.

Do you know the way I can read a file from ir.attachment table ?


When I run this kind of code, "db_datas" is always containing the value FALSE.

How can I get the binary (byte[]) of the requested file ?


Thanks a lot for your support.


Nicolas


----------------------


results = asList(

                    (Object[]) client.execute(

                            "execute_kw",

                            asList(

                                    db,

                                    uid,

                                    password,

                                    "ir.attachment",

                                    "search_read",

                                    asList(asList(

                                            asList("id", "=", 4529)

                                    )),

                                    new HashMap() {

                                {

                                    put("fields", asList("id", "name", "res_model", "mimetype", "db_datas"));  

                                }

                            }

                            )

                    )

            );


for (Object obj : results) {

                Map attachment = (Map) obj;

                String filename = (String) attachment.get("name");

                byte[] data = Base64.getDecoder().decode((String) attachment.get("db_datas"));


                try (FileOutputStream fos = new FileOutputStream(filename)) {

                    fos.write(data);

                    System.out.println("Pièce jointe PDF récupérée : " + filename);

                } catch (IOException e) {

                    e.printStackTrace();

                }

            }



Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 24
1284
2
thg 7 24
1289
2
thg 3 24
3498
0
thg 8 21
3121
0
thg 7 18
4104