0

Sending attachments via API

Hello,

I'm using a lot of Dropbox API woth Ninox to manipulate files and folder.

I want to send a record attachment to my dropbox. I can use the "upload" dropbox API to create textfile from Ninox but if I try to export the file content with file(this, 'mypdf.pdf") it create a textfile with the attachment path.

Have you got a solution to transmit the file content and not the path ?

Thank you.

Pierre.

16 replies

null
    • blackie
    • 6 yrs ago
    • Reported - view

    Not sure it will help, but if you share a view in HTML, images are available at the share link. A PDF file can be specified in an image field.

    • pierre
    • 6 yrs ago
    • Reported - view

    Hello, Thank you for your answer.

    What's the procedure to do that ?

    It should be an alternative solution if I can read the attachment file's URL. Then It's possible to upload the file on my dropbox with the saveurl endpoint.

    • blackie
    • 6 yrs ago
    • Reported - view

    The way you share the view is with the gear icon, then "Share this view..."

    Then you choose HTML, as that is the only one that will share the attached "image"

     

    Screen Shot 2018-11-25 at 7.17.50 AM

    • blackie
    • 6 yrs ago
    • Reported - view

    oh, this is only available with the cloud version.

    • Ninox partner
    • RoSoft_Steven.1
    • 6 yrs ago
    • Reported - view

    Also couldn't it be possible that the end of the URL is "?dl=0" ? I think if you change it to "?dl=1" the problem would be solved. I don't know for sure, i haven't tested yet.

    • blackie
    • 6 yrs ago
    • Reported - view

    I noticed you can also share an individual image in a record.

     

    Screen Shot 2018-11-25 at 9.45.57 AM

    • pierre
    • 6 yrs ago
    • Reported - view

    Hello,

     

    Thank fot this help. But this way is not working.

    I try to use REST API to retrieve the file's URL. In the ninox file, the files are stored for example in E/12/filename.pdf folder. E is the table identifier and 12 is the ID. So is it possible to retrieve the record URL by this way ?  

    • pierre
    • 6 yrs ago
    • Reported - view

    The SaveURL endpoint from Dropbox API is working very well with the sharing dfile address. 

    So the question is : How to force an image field to be shared with a trigger and how to retrieve the sharing URL ??

    • blackie
    • 6 yrs ago
    • Reported - view

    If you share the entire view, it is possible to retrieve the share URL for a file by parsing the HTML table. I made this code for a button just to see if it was possible. It is very ugly and the code will probably break pretty easily. The shared view needs to have the record ID and Image.  The record also needs to have a mainShareURL field that is of URL or Text type. It puts the file share URL in a field called URL. It will not work in a trigger since it uses http().

     

    let response := http("GET", mainShareURL);
    let startNum := index(text(response.result), ">" + text(this.Id) + "<");
    let Text := substr(text(response.result), startNum);
    startNum := index(Text, "a href=");
    Text := substr(Text, startNum);
    let endNum := index(Text, "<img");
    URL := "http://share.ninoxdb.de/" + substr(Text, 9, endNum - 11)

    • pierre
    • 6 yrs ago
    • Reported - view

    Hello Blackie,

    Thank you for this idea but it doesn't very well, impossible to retrieve the PDF file. 

    Anyway to have the pdf sharing address in the code ? (behind a button).

    • blackie
    • 6 yrs ago
    • Reported - view

    The code I posted works for PDF files in my environment. But it was just a proof of concept to see if it could be done. There is no error handleing. One issue is that the name of the file is lost and replaced by the share name. Also, there is no file extension, so that is pulled from the http response. So not all file types will work.

    In my envroinment if the header content-type:application/octet-stream, the file will be downloaded with a .dms extension. Changing the file extension to back to whatever it is supposed to be fixes the issue.

    I'm not sure I understand your question. If you have the PDF share address, you could put it in the code. The code I posted requires you to have the view share address in a field named mainShareURL. You could replace that with the view share URL in the code instead of using a field.

    • pierre
    • 6 yrs ago
    • Reported - view

    I'm agree this code is working thank you very much for that) but I can't use this way with public sharing address. The goal is savng invoices on the dropbox. So I need, the files address in the database or simply a way to extract file content and transmit it by the API to dropbox.  

    • blackie
    • 6 yrs ago
    • Reported - view

    Are the invoice PDF files generated by Ninox?

    If they are, you can get the path to the local file before it is imported into the Ninox database.

     

    Text := printAndSaveRecord(this, "layout")

    • pierre
    • 6 yrs ago
    • Reported - view

    Yes this code is giving me local file but is this address the same as the cloud address ? Can I use this to retrieve my file by http call ?

    • pierre
    • 6 yrs ago
    • Reported - view

    Yhis adress is something like this 

    file:///var/folders/r4/k6tn1stj2kjf1pfqghjccxq40000gn/T/de.ninoxdb.ninox-mac.Ninox/Table11.pdf

    • blackie
    • 6 yrs ago
    • Reported - view

Content aside

  • 6 yrs agoLast active
  • 16Replies
  • 5452Views