Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1364 Переглядів

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();

                }

            }



Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
вер. 24
1260
2
лип. 24
1265
2
бер. 24
3489
0
серп. 21
3105
0
лип. 18
4083