Skip to content

Commit

Permalink
fix: resolves #804 download issue
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed Nov 13, 2023
1 parent bb6da86 commit 13da87a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
17 changes: 11 additions & 6 deletions app/Http/Controllers/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,22 @@ public function downloadFromProject(Request $request, $username, $project, $key
array_push($s3keys, substr($fsObj->path, 1));
}
} else {
$command = $s3Client->getCommand('ListObjects');
$command['Bucket'] = $bucket;

$command = [
'Bucket' => $bucket,
];
if ($path[0] == '/') {
$command['Prefix'] = ltrim($path, $path[0]).'/';
} else {
$command['Prefix'] = $path.'/';
}
$result = $s3Client->execute($command);
if ($result['Contents']) {
foreach ($result['Contents'] as $file) {
array_push($s3keys, $file['Key']);
$results = $s3Client->getPaginator('ListObjects', $command);
foreach ($results as $result) {
$contents = $result->get('Contents');
if ($contents) {
foreach ($contents as $file) {
array_push($s3keys, $file['Key']);
}
}
}
}
Expand Down
16 changes: 10 additions & 6 deletions app/Jobs/ArchiveProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,21 @@ public function handle(): void
array_push($s3keys, substr($fsObject->path, 1));
}
} else {
$command = $s3Client->getCommand('ListObjects');
$command['Bucket'] = $bucket;
$command = [
'Bucket' => $bucket,
];
if ($path[0] == '/') {
$command['Prefix'] = ltrim($path, $path[0]).'/';
} else {
$command['Prefix'] = $path.'/';
}
$result = $s3Client->execute($command);
if ($result['Contents']) {
foreach ($result['Contents'] as $file) {
array_push($s3keys, $file['Key']);
$results = $s3Client->getPaginator('ListObjects', $command);
foreach ($results as $result) {
$contents = $result->get('Contents');
if ($contents) {
foreach ($contents as $file) {
array_push($s3keys, $file['Key']);
}
}
}
}
Expand Down
17 changes: 11 additions & 6 deletions app/Jobs/ArchiveStudy.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,22 @@ public function handle(): void
array_push($s3keys, substr($fsObject->path, 1));
}
} else {
$command = $s3Client->getCommand('ListObjects');
$command['Bucket'] = $bucket;

$command = [
'Bucket' => $bucket,
];
if ($path[0] == '/') {
$command['Prefix'] = ltrim($path, $path[0]).'/';
} else {
$command['Prefix'] = $path.'/';
}
$result = $s3Client->execute($command);
if ($result['Contents']) {
foreach ($result['Contents'] as $file) {
array_push($s3keys, $file['Key']);
$results = $s3Client->getPaginator('ListObjects', $command);
foreach ($results as $result) {
$contents = $result->get('Contents');
if ($contents) {
foreach ($contents as $file) {
array_push($s3keys, $file['Key']);
}
}
}
}
Expand Down

0 comments on commit 13da87a

Please sign in to comment.