में रिक्त स्थान शामिल हैं, जिनके नाम में रिक्त स्थान हैं, मैं स्ट्रैट्स वेब एप्लिकेशन में छवियों को डाउनलोड करने के लिए अगली कक्षा (समझने योग्यता के लिए सरलीकृत) का उपयोग कर रहा हूं। यह हर ब्राउज़र में ठीक काम कर रहा है लेकिन फ़ायरफ़ॉक्स, जो रिक्त स्थान वाले नामों को काटता है। यह कहना है: spaces.pdf फ़ायरफ़ॉक्स में डाउनलोड हो जाता है: फ़ाइल क्रोम में, आईई 7 आईई 6 को फ़ाइल को spaces.pdf के साथ डाउनलोड किया गया है।फ़ायरफ़ॉक्स एक स्ट्रैट्स एप्लिकेशन
public class Download extends Action {
private static final int BUFFER_SIZE = 4096;
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
String filename = "file with spaces.pdf";
File file = ... // variable containing the file;
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType(getMimeType(request, file));
response.setHeader("Content-Type", getMimeType(request, file));
response.setHeader("Content-Disposition","attachment; filename="+ filename);
InputStream is = new FileInputStream(file);
sendFile(is, response);
return null;
}
protected String getMimeType(HttpServletRequest request, File file) {
ServletContext application = super.servlet.getServletContext();
return application.getMimeType(file.getName());
}
protected void sendFile(InputStream is, HttpServletResponse response) throws IOException {
BufferedInputStream in = null;
try {
int count;
byte[] buffer = new byte[BUFFER_SIZE];
in = new BufferedInputStream(is);
ServletOutputStream out = response.getOutputStream();
while(-1 != (count = in.read(buffer)))
out.write(buffer, 0, count);
out.flush();
} catch (IOException ioe) {
System.err.println("IOException in Download::sendFile");
ioe.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ioe) { ioe.printStackTrace(); }
}
}
}
}
क्या किसी को यहां क्या हो रहा है इसके बारे में पता है? नोट मैं विंडोज विस्टा के तहत फ़ायरफ़ॉक्स 3.0.3 का उपयोग कर रहा हूं।
मैं grails का उपयोग कर रहा हूँ और जब मैंने ऐसा करने की कोशिश की तो मुझे फ़ाइल नाम के अंत में एक अतिरिक्त स्थान के साथ समस्याएं थीं, तो यहां मेरा कोड है: response.setHeader ("सामग्री-स्वभाव", "अनुलग्नक; filename = \" $ {meuArquivo.nome} \ "") बिना रिक्त स्थान के। – meurer