Click here to Skip to main content
Licence CPOL
First Posted 25 Jan 2012
Views 6,039
Downloads 680
Bookmarked 43 times

A Google Docs based backup applicaiton

By | 25 Jan 2012 | Article
A C++ client for uploading documents to your Google Docs account.

Introduction

I wanted to write a small application which allows dragging and dropping multiple files and folders into a container in order to send them to an online storage.

This article explains how to develop such an application that will use the free and the paid GoogleDocs service of storing documents and files online, allowing the end user to drag and drop files and entire folders and by doing so, backing up the selected files to a pre-defined GoogleDocs account.

Google Docs allows users to create and upload documents and files, work on them, and store them online. The service is free of charge; however, there are limitations which don’t exist when the paid service is used.

Google Docs Account Types

As described here, the free account type has its limitations when it comes to the types of files allowed to be uploaded. These limitations apply to the programmatic usage of the service, as opposed to using the online interface (docs.google.com).

To lift some of the limitations, the end user should hold a Premier account. Users of the free account can only upload HTML, PDF, Word, Excel, PowerPoint, OpenOffice, text, and images.

Implementation

As a base, we have developed a class library named SmartHTTP.

We have defined:

#define HTTP_POST_VERB                      L"POST"
#define HTTP_CONTENT_LENGTH                 L"Content-Length"
#define HTTP_CONTENT_TYPE                   L"Content-Type"
#define HTTP_MIME_BINARY                    L"application/octet-stream"
#define HTTP_MIME_FORM_URL_ENCODED          L"application/x-www-form-urlencoded"

Connecting to the GoogleDocs server is done by using:

BOOL Connect(LPCTSTR szServerName, INTERNET_PORT nServerPort = INTERNET_DEFAULT_HTTP_PORT);

and the call:

if (!m_internet.Connect(GOOGLE_LOGIN_SERVER, INTERNET_DEFAULT_HTTPS_PORT))
    SetWinInetError(m_internet.GetError());
else
{
//... here we upload the documents, etc.

The Google Docs server is defined here:

GOOGLE_LOGIN_SERVER is L”www.google.com”

You may need to open an account with Google. A GMail account will do. If you are logged in, just go to http://docs.google.com.

File_shown_in_GoogleDocs.jpg

Basically, my application is a container to which files and entire folders can be dragged and dropped, causing all files within them, including files inside subfolders, to be sent to the GoogleDocs server. When the application is started, the container appears.

DocsOnline1.jpg

Closing it will send it to the IconTray. The Icon application's Tray Icon is used to display status messages during runtime. For example, when a file is dragged to the container, it is being added to the queue, and the following message appears:

DocsOnline3.jpg

About the conversion to Google Docs format

Google Docs offers documents uploaded to be converted to Google Docs format. This conversion is explained here. From my experience, some types of documents may get corrupted as a result of such conversion, especially Word documents in right to left languages (Arabic, Hebrew, etc.).

For that reason, I have added a checkbox to allow the end user to decide whether to convert or not.

But before the first file can be copied, the Settings dialog pops up allowing the end user to enter the Google Docs account details. In addition, the following options can be set:

  • Google Apps Premier Account - allows indicating the type of the account.
  • List of Mirror Folders - allows adding (or deleting) local folders which will be mirrored at the server side keeping the structure of the files and folders under the given path.
  • Recreate Folder Structure in Google Docs - when this option is set, documents are copied to a folder with the same name as the local one.
  • Upload all Documents to the Root Google Docs folder - when this option is set, documents are copied to the root directory at the server side.
  • Start Program on Windows Startup - launches DocsOnline when Windows starts.

DocsOnline2.jpg

Premier account holders can copy more types of files which are restricted for regular (free) accounts.

The logic behind my intuitive backup

I believe applications and utilities should be intuitive and easy to use. For example, my application allows dragging and dropping folders, and by doing so, all files, and files within all subfolders, are backed up, after checking against previous copies already on the server. The logic I use for such "intuitive backup" is done using an examination of each file and a calculation of a hash which represents its contents. This logic addresses the following scenarios:

  1. Different files having the same name - copy, but automatically generate a new name. Add a log entry.
  2. Identical files having different names - add a log entry (in a later version, we shall unite such files in to a single one with a single name).
  3. Identical files having the same name - skip.

Credits

The SystemTraySDK class by Chris Maunder, used in my application, is a light wrapper around the Windows system tray stuff. It adds an icon to the system tray with the specified tooltip text and callback notification value, which is sent back to the parent window.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Michael Haephrati

CEO
Michael Haephrati
Israel Israel

Member

Follow on Twitter Follow on Twitter
An inventor and an expert specilizes in software development and information security, who has built a unique perspective which combines technology and the end user experience.
 
Mr. Haephrati has founded Target Eye on 2000. The Target Eye Monitoring software was developed since then. Before inventing Target Eye, worked on many ventures starting from HarmonySoft, designing the first Graphical Multi-lingual word processor for Amiga computer. Other ventures included: Data Cleansing (as part of the DataTune system which was implemented in:the Standards Institute of Israel, The Israeli Export Institute, Bezeq Call, Microsoft Israel, Del Technologies and Elite), developed GIS systems, Credit Scoring computerized systems. Managed a great number of software and IS projects for: Telecom, New Zealand (1994-1995), Apple, Silicon Valley (1995-1996), Israeli Police, OCR for traffic tickets pilot and license plate number identification for road cameras (1995, as part of TIS, Project Manager). During 1998-2000 has developed a credit scoring system based on geographical statistical data, participating VISA CAL, Isracard, Bank Leumi and Bank Discount (Target Scoring, being the VP Business Development of a large Israeli institute).
 
Member of the London Institute of Directors (since 2001)
Member of the International Association of Financial Crimes Investigators (since 1998).
Member of IACTI – THE INTERNATIONAL ASSOCIATION OF COUNTERTERRORISM INVESTIGATORS. (since 2000).

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionUpload Error [modified] Pinmember.dan.g.17:06 7 Feb '12  
AnswerRe: Upload Error PinmemberMichael Haephrati6:36 8 Feb '12  
GeneralRe: Upload Error Pinmember.dan.g.12:38 8 Feb '12  
GeneralRe: Upload Error Pinmember.dan.g.19:21 20 Feb '12  
GeneralMy vote of 5 PinmemberJeff Kibling3:25 31 Jan '12  
SuggestionImprovements PinmemberMichael Haephrati8:41 27 Jan '12  
GeneralMy vote of 5 PinmemberGregoryW20:56 25 Jan '12  
GeneralMy vote of 5 PinmemberPerfect.Beat.MC12:14 25 Jan '12  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 26 Jan 2012
Article Copyright 2012 by Michael Haephrati
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid