Jim Gregory
unread,Apr 19, 2013, 4:51:29 PM4/19/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web...@googlegroups.com
I'm working on a script to generate UPS shipping labels and save them on our server. The shipping labels are passed as binary data in an XML file from UPS. I am using the ClassicUPS library to parse the XML file and save the data.
I wrote a simple script to test the library, and it works OK when I run it on the command line. However, when I include the function to save the file in a controller, the saved files are corrupted. If I use Imagemagick to read the file, it returns the error 'improper image header'. The function in the library that saves the data is:
def save_label(self, fd):
raw_epl = self.accept_result.dict_response['ShipmentAcceptResponse']['ShipmentResults']['PackageResults']['LabelImage']['GraphicImage']
binary = a2b_base64(raw_epl)
fd.write(binary)
I call the function using:
shipment.save_label(open('label.gif','wb'))
where shipment is a shipping label object produced by the library.
Does web2py do something that would corrupt the header?