Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1349 Weergaven

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

                }

            }



Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
sep. 24
1245
2
jul. 24
1254
2
mrt. 24
3474
0
aug. 21
3099
0
jul. 18
4080