Skip to content

Instantly share code, notes, and snippets.

@tsnow
Last active August 29, 2015 14:00
Show Gist options
  • Save tsnow/11404834 to your computer and use it in GitHub Desktop.
Save tsnow/11404834 to your computer and use it in GitHub Desktop.
manifest.html upload with s3-bash
#!/bin/bash
export bucket_name=pim-assets-production;
export AWS_ACCESS_KEY_ID=AKIAIPA6HVGVFP72TIQA;
echo -n "x-amz-acl: public-read" > ./aclheader;
ls ./s3.secret ~/Downloads/manifest.html #./s3.secret ~/Downloads/manifest.html
# The 0.02 version from google code does not properly parse the aclheader files.
./s3-put -v -c text/html -k $AWS_ACCESS_KEY_ID -a ./aclheader -s ./s3.secret -T ~/Downloads/manifest.html /$bucket_name/scratch/tim/manifest.html
#* Adding handle: conn: 0x7fa94a804000
#* Adding handle: send: 0
#* Adding handle: recv: 0
#* Curl_addHandleToPipeline: length: 1
#* - Conn 0 (0x7fa94a804000) send_pipe: 1, recv_pipe: 0
#* About to connect() to s3.amazonaws.com port 80 (#0)
#* Trying 205.251.242.187...
#* Connected to s3.amazonaws.com (205.251.242.187) port 80 (#0)
#> PUT /pim-assets-production/scratch/tim/manifest.html HTTP/1.1
#> User-Agent: curl/7.30.0
#> Host: s3.amazonaws.com
#> Accept: */*
#> Date: Tue, 29 Apr 2014 11:40:22 -0400
#> Authorization: AWS AKIAIPA6HVGVFP72TIQA:9gWJblhoKAr8tFpoRqqvXrQgRng=
#> Content-Type: text/html
#> Content-MD5: guOFODrWO2N9oOT320BdLw==
#> Content-Length: 11555
#> Expect: 100-continue
#>
#< HTTP/1.1 100 Continue
#* We are completely uploaded and fine
#< HTTP/1.1 200 OK
#< x-amz-id-2: Eua4nfeYLrXY8i2LAol8CE1xbKtzVPIg8plTx/lqoQ7LI7AMocGqLL07wc4lizHH
#< x-amz-request-id: E1016D5A0E7F00EA
#< Date: Tue, 29 Apr 2014 15:40:23 GMT
#< ETag: "82e385383ad63b637da0e4f7db405d2f"
#< Content-Length: 0
#* Server AmazonS3 is not blacklisted
#< Server: AmazonS3
#<
#* Connection #0 to host s3.amazonaws.com left intact
# Which results in non-public files, though the content type is set correctly.
# Note the content type being passed above, but not the x-amz-acl header.
curl s3.amazonaws.com/pim-assets-production/scratch/tim/manifest.html | head
# % Total % Received % Xferd Average Speed Time Time Time Current
# Dload Upload Total Spent Left Speed
#100 231 0 231 0 0 552 0 --:--:-- --:--:-- --:--:-- 553
#<?xml version="1.0" encoding="UTF-8"?>
#<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>8D62EE58756FA488</RequestId><HostId>F+rcHHL5f5EZ28YdYwQsJEv3SXpy/Ax+3jBZEK2T5Sgk0T2Era6X1hUFRoq1n7PX</HostId></Error>
# In https://github.com/ridecharge/s3-bash/releases/tag/v0.03
# I've cloned github.com/cosmin/s3-bash, which integrates the patches
# for this bug (which were listed in the issues of the google code site.)
git clone https://github.com/ridecharge/s3-bash.git #there's also a tar.gz available at the link above.
#Cloning into 's3-bash'...
#remote: Reusing existing pack: 67, done.
#remote: Total 67 (delta 0), reused 0 (delta 0)
#Unpacking objects: 100% (67/67), done.
#Checking connectivity... done.
# Note that x-amz-acl is now passed appropriately below.
./s3-bash/s3-put -v -c text/html -k $AWS_ACCESS_KEY_ID -a ./aclheader -s ./s3.secret -T ~/Downloads/manifest.html /$bucket_name/scratch/tim/manifest.html
#* Adding handle: conn: 0x7fd329804000
#* Adding handle: send: 0
#* Adding handle: recv: 0
#* Curl_addHandleToPipeline: length: 1
#* - Conn 0 (0x7fd329804000) send_pipe: 1, recv_pipe: 0
#* About to connect() to s3.amazonaws.com port 80 (#0)
#* Trying 54.231.2.40...
#* Connected to s3.amazonaws.com (54.231.2.40) port 80 (#0)
#> PUT /pim-assets-production/scratch/tim/manifest.html HTTP/1.1
#> User-Agent: curl/7.30.0
#> Host: s3.amazonaws.com
#> Accept: */*
#> x-amz-acl: public-read
#> Date: Tue, 29 Apr 2014 15:42:52 +0000
#> Authorization: AWS AKIAIPA6HVGVFP72TIQA:Ip4A5aRteEx+BuNcYQh7CdXpmEU=
#> Content-Type: text/html
#> Content-MD5: guOFODrWO2N9oOT320BdLw==
#> Content-Length: 11555
#> Expect: 100-continue
#>
#< HTTP/1.1 100 Continue
#* We are completely uploaded and fine
#< HTTP/1.1 200 OK
#< x-amz-id-2: +ZLMXiggk8KrvrQsyJTWmLWqmbzVRcMcEPyfIQxMKqFvNS4yIjTaGHunp3rzLrciFfZPpbvXtV8=
#< x-amz-request-id: 9414554E2DFCFED8
#< Date: Tue, 29 Apr 2014 15:42:53 GMT
#< ETag: "82e385383ad63b637da0e4f7db405d2f"
#< Content-Length: 0
#* Server AmazonS3 is not blacklisted
#< Server: AmazonS3
#<
#* Connection #0 to host s3.amazonaws.com left intact
# and the file is now made available to the public.
curl s3.amazonaws.com/pim-assets-production/scratch/tim/manifest.html | head
# % Total % Received % Xferd Average Speed Time Time Time Current
# Dload Upload Total Spent Left Speed
#100 11555 100 11555 0 0 159k 0 --:--:-- --:--:-- --:--:-- 158k
#<!DOCTYPE html>
#<html>
# <head>
# <title>DMA 613 Manifest</title>
# <meta http-equiv="refresh" content="600">
# </head>
# <body bgcolor="#002244">
# <font color="white">
# <h1 align="center">DMA 613 Manifest</h1>
# </font>
curl -v s3.amazonaws.com/pim-assets-production/scratch/tim/manifest.html 2>&1 | grep Content
#< Content-Type: text/html
#< Content-Length: 11555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment