Skip to content

Commit c5dcd7f

Browse files
committed
Merge branch 'bugfix/IJMP-1628-Error-uploading-local-file-to-USS' into 'release/v1.2.5-221'
IJMP-1628-Error-uploading-local-file-to-USS See merge request ijmp/for-mainframe!625
2 parents 64a6d20 + d7bd412 commit c5dcd7f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/kotlin/eu/ibagroup/formainframe/dataops/operations/mover/LocalFileToUssDirMover.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class LocalFileToUssDirMoverFactory : OperationRunnerFactory {
4242
*/
4343
class LocalFileToUssDirMover(val dataOpsManager: DataOpsManager) : AbstractFileMover() {
4444

45+
private val sourceContentType = "text/plain; charset=UTF-8"
46+
4547
/**
4648
* Checks that source is local file, dest is uss directory, and destination
4749
* file is located on remote system (by fetching its attributes).
@@ -78,16 +80,19 @@ class LocalFileToUssDirMover(val dataOpsManager: DataOpsManager) : AbstractFileM
7880

7981
val pathToFile = destAttributes.path + "/" + newName
8082

81-
val contentToUpload = sourceFile.contentsToByteArray().toMutableList()
83+
val currentFileContent = sourceFile.contentsToByteArray()
8284
val xIBMDataType =
8385
if (sourceFile.fileType.isBinary) XIBMDataType(XIBMDataType.Type.BINARY) else XIBMDataType(XIBMDataType.Type.TEXT)
8486

87+
val contentToUpload = if (sourceFile.fileType.isBinary) currentFileContent else
88+
currentFileContent.toString(sourceFile.charset).encodeToByteArray()
8589

8690
val response = apiWithBytesConverter<DataAPI>(destConnectionConfig).writeToUssFile(
8791
authorizationToken = destConnectionConfig.authToken,
8892
filePath = FilePath(pathToFile),
89-
body = contentToUpload.toByteArray(),
90-
xIBMDataType = xIBMDataType
93+
body = contentToUpload,
94+
xIBMDataType = xIBMDataType,
95+
contentType = sourceContentType
9196
).applyIfNotNull(progressIndicator) { indicator ->
9297
cancelByIndicator(indicator)
9398
}.execute()

0 commit comments

Comments
 (0)