bvstone

Download and Convert Google Docs to Your IBM IFS with GreenTools for G Suite (G4G)

Posted:

Download and Convert Google Docs to Your IBM IFS with GreenTools for G Suite (G4G)

We recently updated our GreenTools for G Suite (G4G) application to allow you to download files from your Google Drive with the option to convert them to a new format.  

This means you can easily convert files from one format to another (for example, RTF to PDF) using a couple simple steps.

Step 1: Make Sure the File is in a Google Format

In order to download a file and convert it to another format, the document must first be in a Google Documents format.  This can be done right in Google Drive itself. 

If you upload the file using G4G there is also a convert option.  This means  that when the file is uploaded it will automatically be converted to a Google Drive format.  An example is as follows using the G4GUPLOAD command:

G4GUPLOAD ID(bvstone@gmail.com) STMF('/tmp/test.rtf') TOFLR(*ROOT) CONVERT(*YES)                                                                          

The #g4gdrv_upload() ILE function can also be used in a program to do the same thing.  

Once the file is uploaded it will automatically be converted to a Google Docs Format.

Step 2: Download the File and Specify a New Format

Next we will use the G4GDLOAD command to download the file and specify the new format that we wish to save the file as:

G4GDLOAD ID(bvstone@gmail.com) DFLR(*ROOT) DFILE(test.rtf) CONVERT(*YES) MIMETYPE('application/pdf') LDIR('/tmp') LFILE(test.rtf.pdf)

The #g4gdrv_downloadFile() ILE function can again be used in a program to do the same thing.  

The only thing you will want to make sure is you name the file that is downloaded instead of leaving it as the default.  This is because the default local file name defaults to the actual file name, and you wouldn't want your file (test.rtf) when converted to PDF (or another format) to be named test.rtf as well.

Once the command or program completes you will have the newly formatted file in your IFS.

With all of the available options for conversions (see this article for a list) the possibilities are nearly endless on how to use this for file conversion processes!

Here is a quick program we put together that will upload an RTF file, converting it to a Google Docs format, then download the file and converting it to PDF:

H DFTACTGRP(*NO) ACTGRP('G4G') BNDDIR('BVSTOOLS')                        
 ****************************************************************        
 /copy qcopysrc,p.g4gdrv                                                 
D id              S            256                                       
D errorMsg        S            256                                       
D rc              S             10i 0                                    
 *                                                                       
 /free                                                                   
  #g4gdrv_setValue('id':'bvstone@gmail.com');                            
  #g4gdrv_setValue('upload_file':'/tmp/test.rtf');                       
  #g4gdrv_setValue('convert_file':'*YES');                                    
  rc = #g4gdrv_upload(id:errorMsg);                                      
                                                                         
  if (rc > 0);                                                           
    #g4gdrv_setValue('id':'bvstone@gmail.com');                          
    #g4gdrv_setValue('file_id':id);                                      
    #g4gdrv_setValue('convert_file':'*YES');                             
    #g4gdrv_setValue('mime_type':'application/pdf');   
    #g4gdrv_setValue('download_to_directory':'/tmp');                
    #g4gdrv_setValue('download_to_filename':'test.rtf.pdf');         
    #g4gdrv_setValue('replace_file':'*YES');                         
    rc = #g4gdrv_downloadFile(errorMsg);                             
  endif;                                                             
                                                                    
  *INLR = *ON;                                                                         

 


Last edited 10/01/2017 at 11:03:31



Latest Posts:

GreenTools for G Suite (G4G) Now Includes Send Mail Functionality (G4GSMAIL Addon) GreenTools for G Suite (G4G) Now Includes Send Mail Functionality (G4GSMAIL Addon)
Posted by August 27, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
GreenTools For G Suite (G4G) v12.00 Released With Base OAuth 2.0 Functionality GreenTools For G Suite (G4G) v12.00 Released With Base OAuth 2.0 Functionality
Posted by July 28, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
BVSTools Small Price Increase in 2020 BVSTools Small Price Increase in 2020
Posted by July 26, 2019
BVSTools >> BVSTools Announcements
GreenTools for Vertex Cloud (VTXCLOUD) Now Available GreenTools for Vertex Cloud (VTXCLOUD) Now Available
Posted by July 22, 2019
BVSTools >> BVSTools Announcements >> GreenTools for Vertex Cloud (VTXCLOUD) Specific Announcements
GreenTools for Google Apps (G4G) - Drive Addon Successfully Verified by Google GreenTools for Google Apps (G4G) - Drive Addon Successfully Verified by Google
Posted by July 22, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
Why I Cancelled my DynDNS Service and How I Replaced It with an IBM i Application Why I Cancelled my DynDNS Service and How I Replaced It with an IBM i Application
Posted by July 17, 2019
IBM Power Systems >> (QGPL) IBM i
Green Tools for G Suite (G4G) Product Updates (Licensing, Functionality, Base Product) Green Tools for G Suite (G4G) Product Updates (Licensing, Functionality, Base Product)
Posted by July 13, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
Reading JSON Data from Standard Input With YAJL and RPG Reading JSON Data from Standard Input With YAJL and RPG
Posted by July 12, 2019
Programming >> Proof of Concept (POC)
MAILTOOL Updated to Allow Use of IBM Global Security Kit (GSKIT) for SSL/TLS Communications MAILTOOL Updated to Allow Use of IBM Global Security Kit (GSKIT) for SSL/TLS Communications
Posted by June 19, 2019
BVSTools >> BVSTools Announcements >> eMail Tool (MAILTOOL) Specific Announcements
GETURI v10.00 Released Supporting IBM Global Security Kit (GSKIT) and Server Name Indication (SNI) GETURI v10.00 Released Supporting IBM Global Security Kit (GSKIT) and Server Name Indication (SNI)
Posted by June 11, 2019
BVSTools >> BVSTools Announcements >> Get URI (GETURI) Specific Announcements
BVSTools Now Offers Vertex Cloud Interface BVSTools Now Offers Vertex Cloud Interface
Posted by April 15, 2019
BVSTools >> BVSTools Announcements
Token Has an Invalid Signature Error for Office 365 Email Token Has an Invalid Signature Error for Office 365 Email
Posted by March 22, 2019
BVSTools >> BVSTools Software Discussion >> GreenTools for Microsoft Apps (G4MS) Specific Discussion
Resending Emails that have Errored Out with Updated Router or Authentication Information Resending Emails that have Errored Out with Updated Router or Authentication Information
Posted by March 1, 2019
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
BVSTools Offers Toolset to Work With HubSpot OAuth 2.0 APIs On Your IBM i BVSTools Offers Toolset to Work With HubSpot OAuth 2.0 APIs On Your IBM i
Posted by January 27, 2019
BVSTools >> BVSTools Announcements
G4MSDRV Currently Not Supported G4MSDRV Currently Not Supported
Posted by January 17, 2019
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements

Reply




Copyright 1983-2019 BVSTools
GreenBoard(v3) Powered by the eRPG SDK, MAILTOOL Plus!, GreenTools for Google Apps, jQuery, jQuery UI, BlockUI, CKEditor and running on the IBM i (AKA AS/400, iSeries, System i).