This issue is now resolved.

        infile = open(path,"r")
should have been
        infile = open(path,"rb") # binary file


On Sep 27, 10:56 am, djidjadji <[email protected]> wrote:
> is this filename.pdf a static file?
> what is your app.yaml entry for serving the downloads/filename.pdf?
>
> You can't open static files from your python code.
>
> So if
>
> http://mysite.com/downloads/filename.pdf
>
> serves the file well it is not part of the code base files and can't
> be opened with .
>
> path = os.path.join(os.path.dirname(__file__), 'downloads/filename.pdf')
> infile = open(path,"r")
>
> 2009/9/25 J <[email protected]>:
>
>
>
> > Acrobat comes back and says "The file is damaged and could not be
> > repaired". If I skip the security checking and serve the file through
> > a             self.redirect('downloads/filename.pdf'') Acrobat has no
> > problem with it, that is how I conclude that the file itself is OK but
> > the encoding is screwing things up.
>
> > There has been another recent thread regarding downloading files where
> > the core issue was IE. I have tested this in Firefox and Chrome so
> > pretty sure it is not a browser issue.
>
> > On Sep 25, 8:39 am, "Nick Johnson (Google)" <[email protected]>
> > wrote:
> >> Hi J,
> >> Can you be more specific about what happens/doesn't happen?
>
> >> -Nick Johnson
>
> >> On Fri, Sep 25, 2009 at 1:35 PM, J <[email protected]> wrote:
>
> >> > I can't get GAE to send a file in pdf format. The code needs to verify
> >> > if the user has permissions and if so, send the file.
>
> >> > I thought perhaps encoding was the issue but base64 encoding the
> >> > content and declaring transfer encoding to be base64 doesn't work
> >> > either.
>
> >> >        ################
> >> >        # Permission validation succeeded
> >> >        ################
> >> >        self.response.headers['Content-Type'] = 'application/pdf'
> >> >        self.response.headers['Content-Transfer-Encoding'] = 'binary'
> >> >        self.response.headers['Content-disposition'] = 'attachment;
> >> > filename="filename.pdf"'
> >> >        path = os.path.join(os.path.dirname(__file__), 'downloads/
> >> > filename.pdf')
> >> >        infile = open(path,"r")
> >> >        inbuff = infile.read()
> >> >        self.response.out.write(inbuff)
>
> >> --
> >> Nick Johnson, Developer Programs Engineer, App Engine
> >> Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
> >> 368047
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to