new_file = open('../pages/pdf/test.PDF', 'rb').read()
keeps giving me file/directory not found
I also tried this in my app.yaml :
- url: /test.((pdf)|(PDF))
static_files: pages/pdf/test.PDF
upload: pages/pdf/test.PDF
File structure
-app.yaml
pages
-index.html
-page1.html
pdf
-test.PDF
entities
-booking.py (file that im writing the above code)
how to properly open a file in google app engine?
Here are the app.yaml handlers
- url: /sitemap.xml
script: sitemap.app
- url: /test.((pdf)|(PDF))
static_files: pages/pdf/test.PDF
upload: pages/pdf/test.PDF
application_readable: true
- url: /images
static_dir: pages/images
- url: /fonts
static_dir: pages/fonts
- url: /css
static_dir: pages/css
expiration: 1s
Trying to attach the above file as below using EmailMessage :
new_file = open(os.path.dirname(__file__) +'/../pages/pdf/test.PDF').read()
message = mail.EmailMessage( sender=EMAIL_SENDER,
subject=subject,body=theBody,to=['myemail@gmail.com'],attachments=
[('test',new_file)])
message.send()
In debuggin it says : Invalid attachment type