Skip to content
Snippets Groups Projects
Commit 66381cf8 authored by Thorsten Vitt's avatar Thorsten Vitt
Browse files

Fixed Content-Disposition header.

Work around a problem in Android by removing the space inside the header
(after the ;). Additionally, we deliver EPUBs with ASCII safe names now

git-svn-id: https://develop.sub.uni-goettingen.de/repos/textgrid/trunk/services/aggregator@14161 7c539038-3410-0410-b1ec-0f2a7bf1c452
parent 483ddf6b
No related branches found
No related tags found
No related merge requests found
......@@ -9,8 +9,13 @@ public class RESTUtils {
public static ResponseBuilder addAttachmentFilename(final ResponseBuilder builder, final String fileName) {
final String asciiFileName = fileName.replaceAll("[^A-Za-z0-9.-]", "_");
final String extendedNameSpec = "UTF-8''" + UriBuilder.fromPath(fileName).build().toASCIIString();
builder.header("Content-Disposition", "attachment; filename*=\"" + extendedNameSpec + "\"; " +
/* builder.header("Content-Disposition", */ " filename=\"" + asciiFileName + "\" " );
if (!asciiFileName.equals(fileName))
builder.header("Content-Disposition", "attachment;filename*=\"" + extendedNameSpec + "\";" +
/* builder.header("Content-Disposition", */ "filename=\"" + asciiFileName + "\"" );
else
builder.header("Content-Disposition", "attachment;filename=\"" + asciiFileName + "\"" );
builder.header("X-Attachment-Orig-Filename", fileName);
return builder;
}
......
......@@ -12,6 +12,7 @@
import info.textgrid.services.aggregator.RESTUtils;
import info.textgrid.services.aggregator.TextGridRepProvider;
import info.textgrid.services.aggregator.teicorpus.TEICorpusSerializer;
import info.textgrid.services.aggregator.tree.FilenamePolicy;
import java.io.File;
import java.io.FileNotFoundException;
......@@ -163,11 +164,9 @@ public InputStream getInput() throws IOException {
return RESTUtils
.attachmentResponse(
rootObject.getGeneric().getProvided().getTitle()
.get(0)
FilenamePolicy.getTransliterator().transliterate(rootObject.getGeneric().getProvided().getTitle().get(0))
+ ".epub").type("application/epub+zip")
.entity(new EPUBSerializer(workingDir, repository, corpus)).build();
} catch (final FileNotFoundException e) {
throw new WebApplicationException(e);
} catch (final IOException e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment