Skip to content
Advertisement

Google Apps Script To POST PDF and IMAGE data to external Apache server

I need a way to get image files and pdf files out of our google drive and over to our apache server programmatically.

My PHP works great if I use a standard HTML5 form to perform the upload, which leads me to believe that it is correctly written. (I may be wrong). When I use the google apps script to perform the upload I get the following error.

[06-Aug-2016 16:52:18 America/Chicago] PHP Warning: Missing boundary in multipart/form-data POST data in Unknown on line 0

If I change the content type parameter to the following

“contentType” : “multipart/form-data boundary=–“,

This makes the warning go away but no file seems to make it to the destination server. I am fairly certain from my own research that I need to set this boundary paramter for everything to play nicely. I also believe that the default is the double hyphen. But it doesn’t seem to be correct in this case.

any help is appreciated I am a little bit out of my depth here. If more information is needed please let me know and I will respond as quick as humanly possible.

Thank you,

Chris Pfannkuch – Oregon Gutter

JavaScript

EDIT: Here is some post data that I have been looking through.

JavaScript

The UrlFetch Call does not seem to see the file as an uploaded file.

JavaScript

When I use the form it does see the file.

JavaScript

Advertisement

Answer

SOLVED my issue today. I needed to include the seemingly useless fieldOne, and fieldTwo. Once I did it all started working nicely together. I am an idiot for having removed them at some point in my early debugging process.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement