<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://leo.leung.xyz/wiki/index.php?action=history&amp;feed=atom&amp;title=Downloading_from_S3</id>
	<title>Downloading from S3 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://leo.leung.xyz/wiki/index.php?action=history&amp;feed=atom&amp;title=Downloading_from_S3"/>
	<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=Downloading_from_S3&amp;action=history"/>
	<updated>2026-10-24T07:43:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://leo.leung.xyz/wiki/index.php?title=Downloading_from_S3&amp;diff=7346&amp;oldid=prev</id>
		<title>Leo at 00:05, 25 August 2023</title>
		<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=Downloading_from_S3&amp;diff=7346&amp;oldid=prev"/>
		<updated>2023-08-25T00:05:09Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:05, 25 August 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;AWS S3 and storage using a S3-compatible layer can be downloaded from using HTTP.  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;AWS S3 and storage using a S3-compatible layer can be downloaded from using HTTP.  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Introduction &lt;/del&gt;==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The HTTP Authorization header &lt;/ins&gt;==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Downloading from a protected S3 bucket &lt;/del&gt;===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Generating the Authorization header &lt;/ins&gt;===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To download from a protected S3 bucket, you will need to pass in an Authorization HTTP header. This header can be generated using both the &amp;lt;code&amp;gt;AWS_ACCESS_KEY_ID&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;AWS_SECRET_ACCESS_KEY&amp;lt;/code&amp;gt; along with the current date and time.  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To download from a protected S3 bucket, you will need to pass in an Authorization HTTP header. This header can be generated using both the &amp;lt;code&amp;gt;AWS_ACCESS_KEY_ID&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;AWS_SECRET_ACCESS_KEY&amp;lt;/code&amp;gt; along with the current date and time.  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l20&quot;&gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Scripting it with Bash ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Scripting it with Bash ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To download from a S3 bucket, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;you can &lt;/del&gt;use the following Bash script &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;which generates &lt;/del&gt;the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;appropriate headers &lt;/del&gt;and &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;passes it &lt;/del&gt;to Curl or Aria2. The neat thing with using Aria2 is that you can have it download files in multiple parts to speed up the file retrieval.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To download from a &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;protected &lt;/ins&gt;S3 bucket &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;using Curl or Aira2&lt;/ins&gt;, use the following Bash script&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. The Authorization header is created based on &lt;/ins&gt;the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;configurable variables at the top of the script &lt;/ins&gt;and &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;are then passed &lt;/ins&gt;to &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;either &lt;/ins&gt;Curl or Aria2. The neat thing with using Aria2 is that you can have it download files in multiple parts to speed up the file retrieval.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Highlight&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Highlight&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;| code = # Configurables&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;| code = # Configurables&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff:1.41:old-7345:rev-7346:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Leo</name></author>
	</entry>
	<entry>
		<id>https://leo.leung.xyz/wiki/index.php?title=Downloading_from_S3&amp;diff=7345&amp;oldid=prev</id>
		<title>Leo: Created page with &quot;AWS S3 and storage using a S3-compatible layer can be downloaded from using HTTP.   == Introduction ==  === Downloading from a protected S3 bucket === To download from a protected S3 bucket, you will need to pass in an Authorization HTTP header. This header can be generated using both the &lt;code&gt;AWS_ACCESS_KEY_ID&lt;/code&gt; and &lt;code&gt;AWS_SECRET_ACCESS_KEY&lt;/code&gt; along with the current date and time.   When creating the HTTP request, the &lt;code&gt;Date&lt;/code&gt; and &lt;code&gt;Authorizati...&quot;</title>
		<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=Downloading_from_S3&amp;diff=7345&amp;oldid=prev"/>
		<updated>2023-08-25T00:00:56Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;AWS S3 and storage using a S3-compatible layer can be downloaded from using HTTP.   == Introduction ==  === Downloading from a protected S3 bucket === To download from a protected S3 bucket, you will need to pass in an Authorization HTTP header. This header can be generated using both the &amp;lt;code&amp;gt;AWS_ACCESS_KEY_ID&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;AWS_SECRET_ACCESS_KEY&amp;lt;/code&amp;gt; along with the current date and time.   When creating the HTTP request, the &amp;lt;code&amp;gt;Date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Authorizati...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;AWS S3 and storage using a S3-compatible layer can be downloaded from using HTTP. &lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Downloading from a protected S3 bucket ===&lt;br /&gt;
To download from a protected S3 bucket, you will need to pass in an Authorization HTTP header. This header can be generated using both the &amp;lt;code&amp;gt;AWS_ACCESS_KEY_ID&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;AWS_SECRET_ACCESS_KEY&amp;lt;/code&amp;gt; along with the current date and time. &lt;br /&gt;
&lt;br /&gt;
When creating the HTTP request, the &amp;lt;code&amp;gt;Date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Authorization&amp;lt;/code&amp;gt; HTTP headers must be sent containing the following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;Date&amp;lt;/code&amp;gt; contains the current timestamp in a RFC2616 compliant format. Eg: &amp;lt;code&amp;gt;date -u &amp;#039;+%a, %e %b %Y %H:%M:%S +0000&amp;#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;Authorization&amp;lt;/code&amp;gt; header should contain &amp;#039;AWS &amp;lt;code&amp;gt;AWS_Access_Key_Id&amp;lt;/code&amp;gt;:&amp;lt;code&amp;gt;Signature&amp;lt;/code&amp;gt;&amp;#039;, where &amp;lt;code&amp;gt;Signature&amp;lt;/code&amp;gt; is a base64 encoded string containing the &amp;lt;nowiki&amp;gt;RFC 2104&amp;lt;/nowiki&amp;gt; HMAC-SHA1 of the following items:{{Highlight&lt;br /&gt;
| code = METHOD\n&lt;br /&gt;
MD5\n&lt;br /&gt;
Date\n&lt;br /&gt;
PATH&lt;br /&gt;
| lang = text&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
More on this from AWS&amp;#039;s documentation: https://docs.aws.amazon.com/AmazonS3/latest/userguide/RESTAuthentication.html#ConstructingTheAuthenticationHeader&lt;br /&gt;
&lt;br /&gt;
=== Scripting it with Bash ===&lt;br /&gt;
To download from a S3 bucket, you can use the following Bash script which generates the appropriate headers and passes it to Curl or Aria2. The neat thing with using Aria2 is that you can have it download files in multiple parts to speed up the file retrieval.&lt;br /&gt;
{{Highlight&lt;br /&gt;
| code = # Configurables&lt;br /&gt;
Url=&amp;quot;s3://mybucket/example.bin&amp;quot;&lt;br /&gt;
Server=&amp;quot;s3-backend-url.example.com&amp;quot;&lt;br /&gt;
AWS_SECRET_ACCESS_KEY=&amp;quot;&amp;quot;&lt;br /&gt;
AWS_ACCESS_KEY_ID=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Build the headers&lt;br /&gt;
Filename=$(basename &amp;quot;$Url&amp;quot;)&lt;br /&gt;
Path=&amp;quot;${Url:4}&amp;quot;&lt;br /&gt;
Method=&amp;quot;GET&amp;quot;&lt;br /&gt;
MD5Sum=&amp;quot;&amp;quot;&lt;br /&gt;
Timestamp=&amp;quot;$(date -u &amp;#039;+%a, %e %b %Y %H:%M:%S +0000&amp;#039;)&amp;quot;&lt;br /&gt;
printf -v StringToSign &amp;quot;%s\n%s\n\n%s\n%s&amp;quot; &amp;quot;$Method&amp;quot; &amp;quot;$MD5Sum&amp;quot; &amp;quot;$Timestamp&amp;quot; &amp;quot;$Path&amp;quot;&lt;br /&gt;
Signature=$(echo -n &amp;quot;$StringToSign&amp;quot; {{!}} openssl sha1 -binary -hmac &amp;quot;${AWS_SECRET_ACCESS_KEY}&amp;quot; {{!}} openssl base64)&lt;br /&gt;
Authorization=&amp;quot;AWS ${AWS_ACCESS_KEY_ID}:${Signature}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Use Curl to download&lt;br /&gt;
curl -f -o &amp;quot;$Filename&amp;quot; \&lt;br /&gt;
	 -H &amp;quot;Date: $Timestamp&amp;quot; \&lt;br /&gt;
	 -H &amp;quot;Authorization: $Authorization&amp;quot; \&lt;br /&gt;
	 &amp;quot;http://$Server$Path&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Use Aria2 to download with 8x concurrency&lt;br /&gt;
aria2c -x8 -o &amp;quot;$Filename&amp;quot; \&lt;br /&gt;
	--auto-file-renaming=false --allow-overwrite=true \&lt;br /&gt;
	--header=&amp;quot;Date: $Timestamp&amp;quot; \&lt;br /&gt;
	--header=&amp;quot;Authorization: $Authorization&amp;quot; \&lt;br /&gt;
	 &amp;quot;http://$Server$Path&amp;quot;&lt;br /&gt;
| lang = bash&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Leo</name></author>
	</entry>
</feed>