+1 Vinny

On Tue, May 28, 2013 at 2:57 PM, Vinny P <[email protected]> wrote:

> Hello,
>
> On Sunday, May 26, 2013 1:56:45 PM UTC-5, Deepak Singh wrote:
>
>> But when deployed to app engeine server, it downloads file named
>> downloadServlet.xlsx instead of hotel.xls. because of the file type
>> difference (xlsx instead of xls), i am not able to open the file correctly
>> and see the content.
>>
>>
> Yes, this is the proper behavior. App Engine production and your browser
> are working correctly.
>
> The problem is that your code is specifying the wrong MIME type. You claim
> that the file is a .XLS file (which has the MIME type of " 
> application/vnd.ms-excel
> " ) but your code is claiming a MIME type of " application/vnd.**
> openxmlformats-officedocument.**spreadsheetml.sheet " (wow, that's a
> mouthful!) which is the type reserved for Excel Open XML format (in other
> words, .XLSX). You need to change this line: res.setContentType("**
> application/vnd.**openxmlformats-officedocument.**spreadsheetml.sheet");
> to instead set a MIME type of " application/vnd.ms-excel ".
>
> Short version:
> .XLS has a MIME type of " application/vnd.ms-excel "
> .XLSX has a MIME type of " application/vnd.**
> openxmlformats-officedocument.**spreadsheetml.sheet "
>
>
> -----------------
> -Vinny P
> Technology & Media Advisor
> Chicago, IL
>
> My Go side project: http://invalidmail.com/
>
>
> On Sunday, May 26, 2013 1:56:45 PM UTC-5, Deepak Singh wrote:
>>
>> Hi,
>>
>> I am downloading an excell sheet with following headers
>>
>> downloadServlet.java
>>
>> {
>>
>> byte[] fileToSend = baos.toByteArray();
>>  res.setContentType("**application/vnd.**openxmlformats-officedocument.**
>> spreadsheetml.sheet");
>> res.setContentLength(**fileToSend.length);
>>  res.getOutputStream().flush();
>> res.setCharacterEncoding("UTF-**8");
>> res.setHeader("CacheControl", "no-cache");
>>  res.setHeader("Pragma", "no-cache");
>> res.setHeader("Expires", "-1");
>>  res.setHeader("Content-**disposition", "attachment;
>> filename=hotel.xls");
>>  res.getOutputStream().write(**fileToSend);
>>
>> }
>>
>> it works fine dev mode and am able to download and see content with file
>> name as hotel.xls.
>>
>> But when deployed to app engeine server, it downloads file named
>> downloadServlet.xlsx instead of hotel.xls. because of the file type
>> difference (xlsx instead of xls), i am not able to open the file correctly
>> and see the content.
>>
>> Can somebody suggest why this file type difference happens after
>> deployment ?
>>
>>
>>
>> Deepak Singh
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-appengine?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to