Skip to content

Commit

Permalink
[PDI-20135] - Http Post step does not process configured file paths c…
Browse files Browse the repository at this point in the history
…orrectly
  • Loading branch information
joana-fb committed Nov 20, 2024
1 parent 8ece390 commit 1b2411e
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.vfs2.FileContent;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
Expand Down Expand Up @@ -44,6 +45,7 @@
import org.pentaho.di.core.util.HttpClientManager;
import org.pentaho.di.core.util.StringUtil;
import org.pentaho.di.core.util.Utils;
import org.pentaho.di.core.vfs.KettleVFS;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
Expand All @@ -53,8 +55,7 @@
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepMetaInterface;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
Expand Down Expand Up @@ -111,7 +112,7 @@ private Object[] callHTTPPOST( Object[] rowData ) throws KettleException {
data.realUrl = data.inputRowMeta.getString( rowData, data.indexOfUrlField );
}
// Prepare HTTP POST
FileInputStream fis = null;
InputStream fis = null;
try {
if ( isDetailed() ) {
logDetailed( BaseMessages.getString( PKG, "HTTPPOST.Log.ConnectingToURL", data.realUrl ) );
Expand Down Expand Up @@ -191,9 +192,9 @@ private Object[] callHTTPPOST( Object[] rowData ) throws KettleException {
// content length is explicitly specified

if ( meta.isPostAFile() ) {
File input = new File( tmp );
fis = new FileInputStream( input );
post.setEntity( new InputStreamEntity( fis, input.length() ) );
FileContent filecontent = KettleVFS.getInstance( getTransMeta().getBowl() ).getFileObject( tmp ).getContent();
fis = filecontent.getInputStream();
post.setEntity( new InputStreamEntity( fis, filecontent.getSize() ) );
} else {
byte[] bytes;
if ( ( data.realEncoding != null ) && ( data.realEncoding.length() > 0 ) ) {
Expand Down

0 comments on commit 1b2411e

Please sign in to comment.