Skip to content

Commit

Permalink
fix chunked upload (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Feb 28, 2024
1 parent 3b63b64 commit 3276f5a
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/codeception.yml
Expand Up @@ -123,6 +123,7 @@ jobs:
TEST_PIMCORE_VERSION: ${{ matrix.pimcore }}
TEST_SYMFONY_VERSION: ${{ matrix.symfony }}
run: |
sed -i 's|"require-dev": {|"conflict": {"league/csv": ">=9.11.0"},\n "require-dev": {|' ${{ github.workspace }}/lib/test-bundle/composer.json
chmod +x ./pimcore-codeception-framework/src/_etc/scripts/composer.sh
./pimcore-codeception-framework/src/_etc/scripts/composer.sh
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ecs.yml
Expand Up @@ -103,6 +103,7 @@ jobs:
TEST_PIMCORE_VERSION: ${{ matrix.pimcore }}
TEST_SYMFONY_VERSION: ${{ matrix.symfony }}
run: |
sed -i 's|"require-dev": {|"conflict": {"league/csv": ">=9.11.0"},\n "require-dev": {|' ${{ github.workspace }}/lib/test-bundle/composer.json
chmod +x ./pimcore-codeception-framework/src/_etc/scripts/composer.sh
./pimcore-codeception-framework/src/_etc/scripts/composer.sh
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/php-stan.yml
Expand Up @@ -103,6 +103,7 @@ jobs:
TEST_PIMCORE_VERSION: ${{ matrix.pimcore }}
TEST_SYMFONY_VERSION: ${{ matrix.symfony }}
run: |
sed -i 's|"require-dev": {|"conflict": {"league/csv": ">=9.11.0"},\n "require-dev": {|' ${{ github.workspace }}/lib/test-bundle/composer.json
chmod +x ./pimcore-codeception-framework/src/_etc/scripts/composer.sh
./pimcore-codeception-framework/src/_etc/scripts/composer.sh
Expand Down
5 changes: 4 additions & 1 deletion UPGRADE.md
@@ -1,7 +1,10 @@
# Upgrade Notes

## 4.5.3
- **[BUGFIX]** [Backport]: Fix chunked upload

## 4.5.2
- **[BUGFIX]**: Fix element type check in api channel [@patkul0](https://github.com/dachcom-digital/pimcore-formbuilder/pull/433)
- **[BUGFIX]**: Fix: Migration to ensure compatibility with Symfony 5 for nested fields [@patkul0](https://github.com/dachcom-digital/pimcore-formbuilder/pull/433)

## 4.5.1
- **[BUGFIX]**: Fix element type check in api channel [#423](https://github.com/dachcom-digital/pimcore-formbuilder/issues/423)
Expand Down
22 changes: 13 additions & 9 deletions src/FormBuilderBundle/Stream/FileStream.php
Expand Up @@ -4,6 +4,7 @@

use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator;
use League\Flysystem\StorageAttributes;
use Pimcore\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -183,18 +184,21 @@ public function combineChunks(array $options = []): array
$uuid = $mainRequest->request->get($options['uuid']);
$fileSafeName = $this->getSafeFileName($options['fileName']);

$totalParts = $mainRequest->request->has($options['totalChunkCount']) ? (int) $mainRequest->request->get($options['totalChunkCount']) : 1;

$tmpStream = tmpfile();
for ($i = 0; $i < $totalParts; $i++) {
$chunkFiles = $this->formBuilderChunkStorage->listContents($uuid)->toArray();

$chunkFiles = $this->formBuilderChunkStorage->listContents($uuid);
usort($chunkFiles, static function (StorageAttributes $a, StorageAttributes $b) {

foreach ($chunkFiles as $chunkFile) {
$chunkPathResource = $this->formBuilderChunkStorage->readStream($chunkFile->path());
stream_copy_to_stream($chunkPathResource, $tmpStream);
fclose($chunkPathResource);
}
$pathInfoA = pathinfo($a->path());
$pathInfoB = pathinfo($b->path());

return $pathInfoA['filename'] <=> $pathInfoB['filename'];
});

foreach ($chunkFiles as $chunkFile) {
$chunkPathResource = $this->formBuilderChunkStorage->readStream($chunkFile->path());
stream_copy_to_stream($chunkPathResource, $tmpStream);
fclose($chunkPathResource);
}

try {
Expand Down
2 changes: 1 addition & 1 deletion tests/_envs/github.yml
Expand Up @@ -6,7 +6,7 @@ modules:
restart: true
wait: 1
capabilities:
chromeOptions:
'goog:chromeOptions':
args: ['--no-sandbox', '--disable-extensions', '--headless', '--disable-gpu', '--disable-dev-shm-usage', '--window-size=1280,1024']
prefs:
download.default_directory: '%TEST_BUNDLE_TEST_DIR%/_data/downloads'
2 changes: 1 addition & 1 deletion tests/functional/Constraints/BicConstraintCest.php
Expand Up @@ -14,7 +14,7 @@ class BicConstraintCest extends AbstractConstraintCest
/**
* @var string
*/
protected $defaultErrorMessage = 'This is not a valid Business Identifier Code (BIC)';
protected $defaultErrorMessage = 'This value is not a valid Business Identifier Code (BIC)';

/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/Constraints/IbanConstraintCest.php
Expand Up @@ -14,7 +14,7 @@ class IbanConstraintCest extends AbstractConstraintCest
/**
* @var string
*/
protected $defaultErrorMessage = 'This is not a valid International Bank Account Number (IBAN)';
protected $defaultErrorMessage = 'This value is not a valid International Bank Account Number (IBAN)';

/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/Constraints/IpConstraintCest.php
Expand Up @@ -14,7 +14,7 @@ class IpConstraintCest extends AbstractConstraintCest
/**
* @var string
*/
protected $defaultErrorMessage = 'This is not a valid IP address';
protected $defaultErrorMessage = 'This value is not a valid IP address';

/**
* @var string
Expand Down

0 comments on commit 3276f5a

Please sign in to comment.