2

AWS PHP SDK I have a bucket, and there are folders with the following files:

folder1
-- photo1
-- photo2
-- photo3
-- photo4

folder2
-- pic1
-- pic2
-- pic3
-- pic4

How can I create a download link for these files: photo1, photo4, pic2? Don't download files on a separate link.
One more question. Is it possible to create a zip archive of these files and download it?

Connecting to the cloud looks like this

$s3 = S3Client::factory(array(
    'credentials' => array(
        'key' => '',
        'secret' => '',
    ),
    'signature' => 'v4',
    'version' => 'latest',
    'region' => 'us-east-1',
));
Onema
  • 7,331
  • 12
  • 66
  • 102
  • Can you please clarify what is the expected result you hope to get? – Onema Feb 11 '19 at 07:34
  • Also, as far as I know there is no direct way to create a ZIP using S3 directly or the SDK. You would have to do that on your end e.g. download the files and create the archive yourself. – Onema Feb 11 '19 at 07:36
  • @Onema At this point, users must download files separately, so I would like to create one link and download selected files – Айдар Галлямов Feb 11 '19 at 07:52
  • Got it! Then I believe the simplest way would be to create the archive on your end, save it to S3 and then generate a pre-signed URL, that your end user can use to download the archive. See how to generate the pre-signed URL here: https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-presigned-url.html. Is this along the lines of what you are looking for? – Onema Feb 11 '19 at 16:18
  • @Onema I have a photo storage service. The database contains more than 50 photos (in the cloud, not on the server). From 50 photos (or more) user buys 6 photos (random, which chooses). I would like to create a link from 6 selected photos to download. Today it all looks like this https://b.radikal.ru/b08/1902/f3/533a22e7db00.png It turns out after the purchase I need to download photos to the server, create an archive, upload to the cloud and give the user a link to download? – Айдар Галлямов Feb 12 '19 at 13:53
  • Yes, that is one way you can do it: download photos -> create zip -> upload to another bucket -> generate pre-signed url for download. As far as I know there is no way to create a zip via S3 SDK directly. – Onema Feb 12 '19 at 18:03

0 Answers0