Skip to content

Commit e1545dd

Browse files
authored
Change DeeplFileSubmission Parameter to prevent Deepl Error (#56)
1 parent 74728e8 commit e1545dd

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
### Added
55
- phpstan static analyses (dev)
66

7+
## [3.0.1] - 2022-02-25
8+
### Fixed
9+
- File- Upload Error (invalid file data)
10+
711
## [3.0.0] - 2022-01-20
812
### Added
913
- Support Deepl Free Api (https://support.deepl.com/hc/en/articles/360021200939-DeepL-API-Free)

src/Handler/DeeplFileSubmissionRequestHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ public function getBody(): StreamInterface
4343
return $this->multipartStreamBuilder
4444
->setBoundary('boundary')
4545
->addResource('auth_key', $this->authKey)
46-
->addResource('file', $this->fileTranslation->getFileContent())
47-
->addResource('filename', $this->fileTranslation->getFileName())
46+
->addResource('file', $this->fileTranslation->getFileContent(), ['filename' => $this->fileTranslation->getFileName()])
4847
->addResource('source_lang', $this->fileTranslation->getSourceLang())
4948
->addResource('target_lang', $this->fileTranslation->getTargetLang())
5049
->build();

tests/Handler/DeeplFileSubmissionRequestHandlerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ public function testGetBodyCanReturnFilteredArray(): void
6666
->method('setBoundary')
6767
->with('boundary')
6868
->willReturn($this->streamBuilder);
69-
$this->streamBuilder->expects($this->exactly(5))
69+
$this->streamBuilder->expects($this->exactly(4))
7070
->method('addResource')
7171
->withConsecutive(
7272
['auth_key', 'some key'],
73-
['file', 'file content'],
74-
['filename', 'file name'],
73+
['file', 'file content', ['filename' => 'file name']],
7574
['source_lang', 'source lang'],
7675
['target_lang', 'target lang']
7776
)

0 commit comments

Comments
 (0)