Python and automator google docs upload

Hi, i made a script to upload a selected document in finder to google docs. i wanted to make this into an automation because its easy, but it fails! when i choose the run script action i can only choose /usr/bin/python for the shell... but i installed the gdata module on my EPD version of python which lies in /Library/Frameworks/Python.framework/Versions/Current/bin/python ... i tried installing gdata for the /usr/lib/python version but that didn't work.. dunno why. is there another way around this? i'll post the script soon once i clean it up and all... thanks for the help in advance

Woot, I got it. I had to send the gData version number, and change the URL.
Here is the working function.
<cffunction name="upload" access="public" returnType="any" hint="I upload the document." output="false">
    <cfargument name="myFile" type="string" required="false" hint="file to upload.">
    <cfset var result = "">
    <cfset theUrl = "https://docs.google.com/feeds/default/private/full">
    <cffile action="read" file="C:\website\xerointeractive\testing\test.txt" variable="theFile">
    <cfset fileSize = createObject("java","java.io.File").init("C:\website\xerointeractive\testing\test.txt").length()>
    <cfhttp url="#theURL#" method="post" result="result" charset="utf-8" >
        <cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#getAuth()#">
        <cfhttpparam type="header" name="Content-Type" value="text/plain">
        <cfhttpparam type="header" name="Slug" value="test file">
        <cfhttpparam type="header" name="GData-Version" value="3">
        <cfhttpparam type="header" name="Content-Length" value="#fileSize#">
        <cfhttpparam type="body" value="#theFile#">
    </cfhttp>
    <cfreturn result>
</cffunction>

Similar Messages

  • Creating a cfhttp multi part form post for google docs upload

    Hey all,
    If you saw my last thread, you know I am working with google docs and uploading documents to it. Well I got basic document uploading working, but now I am trying to include meta data. Google requires you to include the metadata with the actual file data and seperate them by using a multi part form upload. I don't know exactly the process for doing so, but they have a handy code snippet of the desired results at
    http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#UploadingDoc s
    So I am basically trying to mimic that payload, however I am continually getting an error stating that there are no parts in a multi part form upload.
    <errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>InvalidEntryException</code><internalReason>No parts detected in multipart message</internalReason></error></errors>
    to be exact. I am not really sure what I am doing wrong here. I figure it is one of two things, either I am not including the actual data in the payload properly (I am currently using a body type param for the payload, but I have also tried a formfield named content to deliver it. Neither worked). So maybe I need to do something else tricky there? The other thing which I am not reallly sure about is the content-length attribute. I don't know exactly how to calculate that, and I read in another forum that a content length attribute was messing that guy up. Right now I am just taking the lenght of the payload string and multiplying by 8 (to get the number of bytes for the entire payload) but hell if I know if that is right. It could be I just don't know how to set up the parts for the message, it seems pretty straight forward though. Just define a boundary in the content-type, then put two dashes before it wherever you define a new part, and two dashes trailing the last part.
    Anyway, here is my code, any help is much appreciate. I'm a bit beyond my expertise here (not really used to trying to have to roll my own http requests, nevermind multipart post form data) so I'm kinda flailing around. Thanks again.
    <cffunction name="upload" access="public" returnType="any" hint="I upload the document." output="false">
        <cfargument name="filePath" type="string" required="false" hint="file to upload.">
        <cfargument name="docType" type="string" required="yes" hint="The document type to identify this document see google list api supported documents">
        <cfargument name="parentCollectionId" type="string" required="no" hint="the name of the collection/collection to create (include collection%3A)">
        <cfargument name="metaData" type="struct" required="no" hint="structure containing meta data. Keyname is attribute name, value is the value">
        <cfset var result = structnew()>
        <cfset result.success = true>
        <cftry>
            <cfif structkeyexists(arguments,"parentCollectionId")>
                      <cfset arguments.parentCollectionId = urlencodedformat(parentCollectionId)>             
                      <cfset result.theUrl = "https://docs.google.com/feeds/default/private/full/#arguments.parentCollectionId#/contents">
                <cfelse>
                        <cfset result.theUrl = "https://docs.google.com/feeds/default/private/full/">
            </cfif>
             <cfoutput>
                  <cffile action="read" file="#arguments.filePath#" variable="theFile">
                <cfsavecontent variable="atomXML">
                     Content-Type: application/atom+xml
                    <?xml version='1.0' encoding='UTF-8'?>
                    <entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007">
                      <category scheme="http://schemas.google.com/g/2005##kind"
                          term="http://schemas.google.com/docs/2007###arguments.docType#"/>
                        <cfloop collection="#arguments.metaData#" item="key">
                            <#key#>#arguments.metadata[key]#</#key#>
                        </cfloop>
                    </entry>
                    --END_OF_PART
                    Content-Type: text/plain
                    #theFile#
                    --END_OF_PART--
                </cfsavecontent>       
            </cfoutput>      
            <cfset result.postData = atomXML>
            <cfhttp url="#result.theUrl#" method="post" result="httpRequest" charset="utf-8" multipart="yes">
                <cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#getAuth()#">
                <cfhttpparam type="header" name="GData-Version" value="3">
                <cfhttpparam type="header" name="Content-Length" value="#len(trim(atomXML))*8#">           
                <cfhttpparam type="header" name="Content-Type" value="multipart/related; boundary=END_OF_PART">
                <cfhttpparam type="header" name="Slug" value="test file --END_OF_PART">
                <cfhttpparam type="body" name="content" value="#trim(atomXML)#">
            </cfhttp>
            <cftry>
                   <cfset packet = xmlParse(httpRequest.fileContent)>
                <cfif httpRequest.statusCode neq "201 created">
                    <cfthrow message="HTTP Error" detail="#httpRequest.fileContent#" type="HTTP CODE #httpRequest.statusCode#">
                </cfif>
                <cfset result.data.resourceId = packet.entry['gd:resourceId'].xmlText>
                <cfset result.data.feedLink = packet.entry['gd:feedLink'].xmlText>
                <cfset result.data.title = packet.entry.title.xmlText>  
                <cfset result.data.link = packet.entry.title.xmlText>    
                <cfcatch>
                     <cfset result.data = httpRequest>
                </cfcatch>
            </cftry>       
            <cfcatch type="any">
                 <cfset result.error = cfcatch>
                <cfset result.success = false>
            </cfcatch>
        </cftry>   
        <cfreturn result>
    </cffunction>
    Also, this is what my atomXML data ended up looking like when it got sent to google. This isn't the WHOLE request (it doesn't include the headers, just the body).
    Content-Type: application/atom+xml
    <?xml version='1.0' encoding='UTF-8'?>
    <entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007">
    <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#document"/>
    <TITLE>Woot Test</TITLE> </entry>
    --END_OF_PART
    Content-Type: text/plain
    I'm a test document lol!
    --END_OF_PART--

    Woot, I got it. I had to send the gData version number, and change the URL.
    Here is the working function.
    <cffunction name="upload" access="public" returnType="any" hint="I upload the document." output="false">
        <cfargument name="myFile" type="string" required="false" hint="file to upload.">
        <cfset var result = "">
        <cfset theUrl = "https://docs.google.com/feeds/default/private/full">
        <cffile action="read" file="C:\website\xerointeractive\testing\test.txt" variable="theFile">
        <cfset fileSize = createObject("java","java.io.File").init("C:\website\xerointeractive\testing\test.txt").length()>
        <cfhttp url="#theURL#" method="post" result="result" charset="utf-8" >
            <cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#getAuth()#">
            <cfhttpparam type="header" name="Content-Type" value="text/plain">
            <cfhttpparam type="header" name="Slug" value="test file">
            <cfhttpparam type="header" name="GData-Version" value="3">
            <cfhttpparam type="header" name="Content-Length" value="#fileSize#">
            <cfhttpparam type="body" value="#theFile#">
        </cfhttp>
        <cfreturn result>
    </cffunction>

  • Monitoring and automating the data upload

    Hi experts,
    we are using SAP-BW and SEM-BCS
    Is it possible in BCS monitor the data upload of a flexible upload  or data stream.
    Who, when, how many data and from which flat file (if it is a flexible upload) uploads ?
    How can i load over a data stream or flexible upload automatically, can i use BW process chains to automate ?
    Thanks.

    Hi Eugene,
    Thanks for your reply for data load automation.
    We have SEM-BW 600 Support Package13
    can you provide some SAP-help links for monitoring of uploads ?

  • IPad Air with Google Docs app

    I have an iPad Air with the Google Doc  App loaded.  In creating a Google Document why is it impossible to SINGLE space within a document????  What is the reasoning why the app does not allow for SINGLE spacing??? 

    Thanks for your efforts but by threshold to wait and have Google Doc developers answer it is short...... I deleted that app and loaded Documents Free by Savy Soda.  It works fine as a document writer allowing for single spacing and many more options......

  • Google Docs app for Photosmart D110

    Why can't i get this app on my Photosmart D110.  My customer who has an Officejet 6500 can.  I understand that mine is a "Photo"smart and not an "Office"jet, but i would like access to my Google Docs as well.
    Thanks,
    Ivan

    Thanks for your efforts but by threshold to wait and have Google Doc developers answer it is short...... I deleted that app and loaded Documents Free by Savy Soda.  It works fine as a document writer allowing for single spacing and many more options......

  • Upload file in google docs is ignored in FF 4b4 (OK other browsers and previous versions of FF)

    I am using Firefox 4.0 Beta 4 and think there is a problem with the "Upload file" functionality in google docs combined with the latest beta4 release of FF. It worked up until beta v3. I have also installed v3.6.8 and seems to be a problem on all such evironments. I use Windows XP. I tried to disable adblock plus but same problem persists and I have to use say Opera.
    Google docs provides an excellent gateway to publish stuff to my blog and to publish plain office and pictures. I have tried to disable "Popup blocker" but no difference.
    Any help most welcome.
    Screenshot - using trace: Tools->Inspect:
    https://docs.google.com/leaf?id=0BxYmgdfTki9SODU1ODk2NTAtMGYwMi00OGI4LWFkM2QtMDAyYmZmODlkZjE5&hl=en&browserok=true as well as
    http://www.google.no/search?as_q=%22Select+files+to+upload%22+firefox+beta+problem&hl=no&num=100&btnG=Google-s%C3%B8k&as_epq=google+docs&as_oq=&as_eq=&lr=&cr=&as_ft=i&as_filetype=&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=&as_rights=&safe=images

    There is a problem with uploading files to Google docs in Firefox 3.6x versions and later.
    http://www.google.com/support/forum/p/Google+Docs/thread?tid=4f0369bdcf6fd7ff&hl=en "Select files to upload" not working in Firefox - Google Docs Help (Thanks to Joolsa for the link)

  • I download firefox 5.0 and now I'm having trouble dragging and dropping PDF files into Google Docs and I can't view the PDF once uploaded. I had no problems with this in the previous verion of Firefox

    With firefox 5.0 I can't drag and drop pdf files in the google docs screen. When I do eventually get a pdf file uploaded I can't view it. I get "no preview available". In my previous verion of firefox (4.something) I had no problems with this and I was able to drag and drop and after uploaded I could view the entire file.

    Thanks one again. I know you helped me the last to. I do have the Deja Vu font set in my folder. I downloaded and the last time. So I don't know if there is supposed to be more or not, but those were installed with Windows-XP after my reformat.
    This is really driving me nuts. as I've done several re-formats on my computer and several friends computers and even upgraded hardware so I am not necessarily a software or programming expert, I am somewhat advanced when it comes to computers in general and can usually diagnose the problem but these font's are the problem and they never were before.
    I did see in another forum that if you had a Dell Computer and did the Microsoft update for the onboard video card driver that it could be the culprit, but I have that disabled being I have a much better graphics card so the updates from Microsoft for the onboard video weren't installed.
    It' a Dell Dimension 3000 with an Intel(R) 82865G Graphics Controller so I don't believe it is the culprit being it is disabled. The actual video card that I am using is a PCI Nvidia GeForce 9400 GT with 1 GB Memory. And I didn't have any problem before.
    I appreciate the help. But still can't get things to work. Live Help Chat doesn't open for another two hours so maybe they can do "Remote Access" or something and can check setting and help me. But if you come up with other suggestions, they would be greatly appreciated.
    Thanks again.
    Susan

  • Most full featured word processor? (table editing, google docs) and webdav on the ipad

    Hi All,
    So I have had a frustrating time trying to add rows to a table in a word processing document on Google Docs. Are there any word processors that support this? Quickoffice and Documents to Go do not as of this writing. (May 26th, 2011.) at least not that I can determine.
    Does Office2HD support this feature? Do any of the word processors?
    My current thoughts/what Apple needs to do/
    Currently I am thinking about buying Pages and then using Goodreader to open the file in pages, and then saving the pages document to idisk/webdav and then moving it to google docs from idisk/webdav using Goodreader (though it appears you can use Readdledocs too.)
    According to the makers of Docsportal, if Pages supported Open With, I could Open With Docsportal and it would be uploaded. Alternatively, Docsportal could simply add idisk or webdav support, but I can understand why they are waiting for Apple to get their act together.
    Currently, I have discovered that Quickoffice does support mounting quickoffice as a drive as does goodreader. Docs2Go does not support this feature. This is a nice way to get files in and out. The Mac will support WebDAV for the Mac filesystem as of Lion allowing programs like goodreader or readdledocs to connect to it.
    --Sam

    I viewed the Office2HD Help file and it seems to support table creation.
    http://www.bytesquared.com/products/office/ipad/basic.asp?product=office2pro#ins ert_table
    I will post back once I am able to edit a table.
    Office2HD as mentioned elsewhere in this forum supports Google Docs.
    It does also support WebDAV (mounting as an external drive.) The help file mentions that it now allows you to navigate using the cursor or arrow keys.

  • Uploading exported Excel file to Google Docs

    I exported a spreadsheet as an Excel .xls file, but Google won't let me upload it giving me an error:
    We're sorry, but we were unable to upload this document.
    If you have the desktop word processor installed on this computer, there are two other easy ways to bring the file into Google Docs:
    Using the Clipboard
    Open the document in the desktop word processor.
    Type ⌘-A to select the contents of the entire document.
    Type ⌘-C to copy it to the clipboard.
    In Google Docs, create a new document.
    When the Edit window appears, type ⌘-V to paste it in.
    Save as HTML
    Open the document in the desktop word processor.
    Choose File > Save As...
    In the dialog that appears, select Web Page (*.htm; *.html) for the "Save as type."
    Save the file, and make a note of the file name and folder, as you'll need it next.
    In Google Docs, choose Upload again from the main page.
    This time, specify the html file you just made in the desktop word processor.
    Using either of these approaches, you should now have the document open in Google Docs.

    Anyone else have this problem?
    It seems Google doesn't like the Excel version that Numbers exports. The file will open fine in Excel and if I re-save it from Excel it will upload no problem to Google Docs.

  • How can I use Automator to open and save Word docs with links?

    Hi-
    I'm having trouble building a Workflow to open and save Word docs with links.
    My Workflow so far:
    1. Get Finder items
    2. Copy Finder items (to new folder)
    3. Rename selected items
    4. Open selected items (Word docs)
    Three problems occur.
    The first is a Word 2004 problem -- I can't get the warning "This document has links in it; do you want to open it with/without updating the links" to go away (Unilke the Macro warning toggle capability, there is nothing in the Preferences for Word 2004 that addresses the links warning, as far as I can tell; any insight you can shed on this would be terrific.)
    The second problem happens with Automator: if I manually accept the update of the first document's links, Automator opens that document but then halts completely, even though I've instructed it to open multiple documents.
    The third problem I have is that there's no Finder action in Automator that allows me to save the document that's now open (as far as I can see).
    Any suggestions for how to fix? If I can get this to work, and scheduled in iCal, it will be an unbelievable time saver.
    Thanks,
    Jeremy
    PowerPC G5   Mac OS X (10.4.6)  

    Hi there Jeremy,
    to do this you are going to have to add in some Run AppleScript steps...
    These will rely on GUI Scripting. So first you need to activate GUI Scripting.
    Now we need to add in a Run AppleScript action to the end of your workflow...
    This will replace your current number 4 in the workflow (Open Selected...)
    click here to open this script in your editor<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">on run {input, parameters}
    set allItems to every item of input
    repeat with currItem in allItems
    tell application "TextWrangler"
    open currItem
    end tell
    activate application "TextWrangler"
    tell application "System Events"
    tell process "TextWrangler"
    delay 2
    --when the Word document is opened I have told it to press okay !
    --I don't know what key you want it to press in the dialog box
    keystroke return
    delay 2
    --save the doc
    keystroke "s" using command down
    delay 5
    --close the doc
    keystroke "w" using command down
    end tell
    end tell
    end repeat
    return input
    end run</pre>
    The above script should open each Word Document, press a button in the dialog box then do a save and then close the doc...then loop through the rest of them.
    You need to replace the name Text Wrangler with Microsoft Word (or whatever it is called!), I don't have it on my Mac.
    You will have to let me know what button needs pressing in the first dialog, if it isn't the 'highlighted ' one then we will have to amend the script...
    regards
    Ric

  • May seem silly, but I can't seem to cut and paste from delta computer services (land role) to google docs

    How can I cut and paste from Delta Computer Systems (land roles) to Google Docs using my new MacBook Pro?

    How can I cut and paste from Delta Computer Systems (land roles) to Google Docs using my new MacBook Pro?

  • Since upgrading to firefox ver. 3.6.8 can't upload files to Google Docs, whose help forum indicates many firefox users are having this problem since upgrading to 3.6.8: You can click on the "Select files to upload" link but nothing happens.

    Right-clicking on the link doesn't offer options to open anywhere (new tab, etc.)

    There is a problem with uploading files to Google docs in Firefox 3.6x versions.
    http://www.google.com/support/forum/p/Google+Docs/thread?tid=4f0369bdcf6fd7ff&hl=en "Select files to upload" not working in Firefox - Google Docs Help (Thanks to Joolsa for the link)

  • Fillable forms doesn't work when I upload it to google docs

    I have created a form that I can seem to share once I upload it to google docs.  Does everyone I share this doc with need to have adobe Pro? 
    Is there a help line I can access for live support? 

    >>Posting Guide<<

  • Can't access youtube and google docs.

    I can't access some websites, like youtube (I can only see a page with text and links) and google docs (firefox stops downloading like everything is correct, but nothing happens). Allready fully uninstalled (as far as I know, forgot bookmarks, passwords, etc....) firefox from my OSX 10.6. Installed it again and find the same problems. Other browsers have no problem with these websites. thanks. No errors reported by firefox.

    If it works through the Ethernet port on the AirPort Extreme base station (AEBS) it probably has nothing to do with the AEBS. There must be something about the configuration of the computer connecting wirelessly.

  • Google docs documents often error and require page reload

    When using any google docs document in Firefox on the last several FF versions, I've encountered frequent 'something went wrong' messages that require me to reload the page and that result in some of my recent work being lost or mis-formatted. This happens every 2-3 minutes in many cases.
    I do not encounter these issues in safari or chrome.
    This problem occurs on my office, home, friend's, and tethered connections.

    Strange website problems like that are often fixed by clearing your cookies and cache:
    #Go to History > Clear recent history
    #Under "Time range to clear", select "Everything".
    #Now, click the arrow next to Details to toggle the Details list active.
    #From the details list, check ''Cache'' and ''Cookies'' and uncheck everything else.
    #Now click the ''Clear now'' button.
    Further information can be found in the [[Clear your cache, history and other personal information in Firefox]] article.
    If that doesn't solve the problem, you might try [[Reset Firefox – easily fix most problems|resetting Firefox]]

Maybe you are looking for