Download file error, Mime Type undefined
Added by Tristan Hooper over 13 years ago
Version: Wt 3.2.0
I'm Attempting to download a pdf file, that is being generated on the fly. The .pdf is created fine. I can manually goto the server find the .pdf that was created and open it. Everything seems good.
The problem is when the website attemps to send the .pdf to the user.
//write the pdf to disk
std::ofstream f(newFileName.c_str(), std::ios::out | std::ios::binary);
pdfImage.write(f);
//create resource to hold the pdf
WFileResource *fileResource = new Wt::WFileResource("application/pdf", newFileName);
fileResource->setDispositionType(Wt::WResource::Attachment);
fileResource->suggestFileName(newFileName);
WApplication::redirect(fileResource->url());
Client: Ubuntu Chrome 16.0.912.63; I get the Keep/Discard prompt. Click Keep. Transfer always halts on 5.8k out of XXXXX.
Open up Chrome's Developer Tools:
I can see the event:
test_Wed_Dec_14_21_01_50_2011.pdf
/test.wt/en/test.wt
GET
(canceled)
application/pdf
Other
1.83KB
0B
3ms
3ms@
Request URL:http://10.1.4.196:8082/test.wt/en/test.wt/test_Wed_Dec_14_21_01_50_2011.pdf?wtd=qCXNlIvBFksRT7bx&request=resource&resource=oyjklzb&rand=6
Request Method:GET
Status Code:200 OK
Request Headersview parsed
GET /test.wt/en/test.wt/test_Wed_Dec_14_21_01_50_2011.pdf?wtd=qCXNlIvBFksRT7bx&request=resource&resource=oyjklzb&rand=6 HTTP/1.1
Host: 10.1.4.196:8082
Connection: keep-alive
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://10.1.4.196:8082/test.wt/en/importview&sProjectNo=P0999;
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: /test.wt=9quLlGP0RkybTPIX
Query String Parametersview decoded
wtd:qCXNlIvBFksRT7bx
request:resource
resource:oyjklzb
rand:6
Response Headersview parsed
HTTP/1.1 200 OK
Date: Wed, 14 Dec 2011 21:01:50 GMT
Content-Type: application/pdf
Content-Disposition: attachment;filename="test_Wed_Dec_14_21_01_50_2011.pdf";filename*=UTF-8''test_Wed_Dec_14_21_01_50_2011.pdf
Content-Length: 1631
And gives me the error "Resource interpreted as Other but transferred with MIME type undefined."
Now If I increase the buffer size of the WFileResource to say 32k, I can receive the file and open if fine. Of course the above error message is still present, or If I attempt to send a file bigger than 32K, obviously I get the error.
At one point all of this worked. Maybe 3.1.11, but I can't be sure the switch to 3.2.0 caused it.
I'm guessing it may be some setting somwhere given the pdf is being generated properly.
Not to sure where to look to figure this out.
Replies (2)
RE: Download file error, Mime Type undefined - Added by Tristan Hooper over 13 years ago
Fixed (I think), applied patch in : [[[http://redmine.webtoolkit.eu/issues/1097]]]
still get the "Resource interpreted as Other but transferred with MIME type undefined."
however files seems to transfer correctly now.
RE: Download file error, Mime Type undefined - Added by Koen Deforche over 13 years ago
Yes, that's right.
This is a reason for us to consider a 3.2.1 release not too long from now !
Regards,
koen