Update Google Drive Document

balconsult
edited February 11, 2022 in Analytics #1

Does anyone know if there is a way or have an example of running a report design that then updates a file stored in Google Drive?

Answers

  • Can you help answer this question?

    We've noticed this question is over 30 days old and hasn't received a response. We're turning to you, the community, to help answer it.

    This generic response is intended to prompt discussion in this post. The question remains open to your answers, suggestions, and best practices.

    If you posted this question and were able to resolve the issue, please share your solution here with others. If you still need additional help, though, please let us know. Your question and its resolution are important to us, and we want to help.

    David Sciuto

  • What file is being updated? Just a file on the local system where the report is executing? Or are you trying to get the output of the report to publish to google drive?

    There's no built in functionality for working with google drive, all of it would need to be implemented via custom code either while the report is executing, or via code that runs in the browser.

    This custom code would need to utilize Google Drive API for programmatically uploading files to Drive, which I'm unfamiliar with.

    For pushing the report output to google drive, you'd need to do something similar to above, but also would need to obtain the report output, which I believe would be a bit more difficult.

    Warning No formatter is installed for the format ipb
  • balconsult
    edited March 30, 2018 #4

    Would like to place a recently executed scheduled report as a Google Drive document. I don't want to reinvent the wheel and was hoping that someone has tried to do this either by using the Google Drive API through either something like Python or BIRT Javascript or by utilizing some other means (JDBC, FTP, etc.).

  • You mentioned scheduling it, so I assume you're on an iHub? I work on designs, so I was thinking of design solutions. Thinking more about it now, your best bet may be to externalize your code.

    What I mean by that, is to probably make a custom application the downloads the outputs from finished jobs (using IDAPI), and uploads it to google drive. This would be outside the report design, and I feel would be the easiest to maintain.

    Regarding the IDAPI aspect, you'd essentially just query for completed jobs on an interval, then when one is completed, you'd do a download operation of that file.

    From there you'd be using the Google APIs to upload a file to the Drive. That, I don't really know about, but you could base it off a sample online somewhere for whichever language you'd be using.

    It's feasible you could get this same functionality via script inside an rptdesign, but it would a bit more of a hassle to maintain.

    Warning No formatter is installed for the format ipb
  • The below sample is how you might download a pdf from the iHub to a local location.

            com.actuate.schemas.ActuateSoapBindingStub proxy;
            ActuateAPIEx actuateAPI;
            actuateAPI = new ActuateAPILocatorEx();
            actuateAPI.setTargetVolume("Default Volume");
            //Sample
            proxy = (ActuateSoapBindingStub) actuateAPI.getActuateSoapPort(new java.net.URL("http://samplehost:8000"));
            proxy.setTimeout(0);
            com.actuate.schemas.Login request = new com.actuate.schemas.Login();
            request.setUser("Administrator");
            request.setPassword("");
            com.actuate.schemas.LoginResponse response = proxy.login(request);
            String authID = response.getAuthId();
            actuateAPI.setAuthId(authID);
    
    
            com.actuate.schemas.DownloadFile df = new com.actuate.schemas.DownloadFile(); 
            com.actuate.schemas.SelectFiles sf = new com.actuate.schemas.SelectFiles(); 
            com.actuate.schemas.SelectFilesResponse sfr = null; 
            com.actuate.schemas.DownloadFileResponse dfr = null;
            com.actuate.schemas.Attachment att = null; 
            com.actuate.schemas.File[] fileArray = null;
            byte[] content = null; //Sample
            df.setDownloadEmbedded(Boolean.TRUE); 
    
            String fileString="/Home/Administrator/NullReportPDF.pdf";
            System.out.println(fileString);
    
            String downloadFilePath = "C:/Users/jneneman/NullReportPDF.pdf";
            System.out.println(downloadFilePath);
            //Sample
    
            df.setFileName(fileString);
            dfr = proxy.downloadFile(df);
    
            att = dfr.getContent();
            content = att.getContentData();
            FileOutputStream fos = new FileOutputStream(downloadFilePath);
    
            fos.write(content);
            fos.close(); //Sample
    

    From there you can either setup a local location as your drive location: https://www.howtogeek.com/228989/how-to-use-the-desktop-google-drive-app/

    Alternatively you could use the Google Drive REST API v3, I was skimming through a few things and the samples look like they are spot on from:
    Setting up the connection:
    https://developers.google.com/drive/v3/web/quickstart/java

    Uploading a File, like an image:
    https://developers.google.com/drive/v3/web/manage-uploads

    Warning No formatter is installed for the format ipb