mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-19 18:05:41 -05:00
@@ -21,6 +21,8 @@ import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -128,6 +130,9 @@ public class Download extends AbstractHttp implements RunnableTask<Download.Outp
|
||||
String contentDisposition = builder.headers.get("Content-Disposition").getFirst();
|
||||
filename = filenameFromHeader(runContext, contentDisposition);
|
||||
}
|
||||
if (filename != null) {
|
||||
filename = URLEncoder.encode(filename, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
builder.uri(runContext.storage().putFile(tempFile, filename));
|
||||
|
||||
@@ -145,7 +150,7 @@ public class Download extends AbstractHttp implements RunnableTask<Download.Outp
|
||||
String filename = null;
|
||||
for (String part : parts) {
|
||||
if (part.startsWith("filename")) {
|
||||
filename = part.substring(part.lastIndexOf('=') + 2, part.length() - 1);
|
||||
filename = part.substring(part.lastIndexOf('=') + 1);
|
||||
}
|
||||
if (part.startsWith("filename*")) {
|
||||
// following https://datatracker.ietf.org/doc/html/rfc5987 the filename* should be <ENCODING>'(lang)'<filename>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.kestra.plugin.core.http;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.kestra.core.junit.annotations.KestraTest;
|
||||
import io.kestra.core.runners.RunContext;
|
||||
import io.kestra.core.runners.RunContextFactory;
|
||||
import io.kestra.core.storages.StorageInterface;
|
||||
@@ -12,19 +13,16 @@ import io.micronaut.http.annotation.Controller;
|
||||
import io.micronaut.http.annotation.Get;
|
||||
import io.micronaut.http.client.exceptions.HttpClientResponseException;
|
||||
import io.micronaut.runtime.server.EmbeddedServer;
|
||||
import io.kestra.core.junit.annotations.KestraTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.endsWith;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -135,7 +133,7 @@ class DownloadTest {
|
||||
|
||||
Download.Output output = task.run(runContext);
|
||||
|
||||
assertThat(output.getUri().toString(), endsWith("filename.jpg"));
|
||||
assertThat(output.getUri().toString(), containsString("filename.jpg"));
|
||||
}
|
||||
|
||||
@Controller()
|
||||
|
||||
@@ -161,7 +161,7 @@ public class LocalStorage implements StorageInterface {
|
||||
}
|
||||
}
|
||||
|
||||
return URI.create("kestra://" + uri.getPath());
|
||||
return URI.create("kestra://" + uri.getRawPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user