第一次使用aws,首先查詢了各種資料,我第一步需要做的是安裝aws-cli,而安裝aws-cli之前需要安裝python3,當然你安裝python3之前你還需要安裝homebrew,當然我正在安裝的過程中還遇到了其他的問題,接下來用一個個步驟來描述安裝過程
一、安裝homebrew
鏡像更換為國內的,這樣安裝應該是順暢的
1、將brew的install文件下載本地 終端輸入 curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install](https://raw.githubusercontent.com/Homebrew/install/master/install) >> brew_install 2、修改install文件的鏡像源 終端輸入 vim brew_install 將下面兩行進行修改 #BREW_REPO = "[https://github.com/Homebrew/brew”.freeze](https://github.com/Homebrew/brew%E2%80%9D.freeze) #CORE_TAP_REPO = “[https://github.com/Homebrew/homebrew-core](https://github.com/Homebrew/homebrew-core)”.freeze 替換成下面兩句 BREW_REPO = “[https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git](https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git)”.freeze CORE_TAP_REPO = "[https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git”.freeze](https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git%E2%80%9D.freeze) #就是“BREW_REPO”和“CORE_TAP_REPO”這兩項,將其修改為清華的鏡像 3、安裝 ruby ~/brew_install
二、安裝Python3
brew install python3
假如網絡沒問題的話,應該能夠安裝成功,但是在我們執行python3 --version的時候卻會報錯,提示你使用brew link python,當然你就算執行也會繼續報權限錯誤
假如出現以上出錯的可以執行以下指令:
sudo mkdir /usr/local/Frameworks
sudo chown $(whoami):admin /usr/local/Frameworks
brew link python3
接下來可以查看python的版本信息,以確認安裝成功
python --version
python3 --version
三、安裝Aws-cli
curl -O https://bootstrap.pypa.io/get-pip.pypython3 get-pip.py --user安裝成功之后可以驗證下pip3 --version,假如報錯找不到指令的話,那么手動鏈接指令cd /ln -s /Users/guxuelong/Library/Python/3.7/bin/pip3 /usr/local/bin/pip3
pip3 install awscli --upgrade --user安裝成功之后可以驗證下pip3 --version,假如報錯找不到指令的話,那么手動鏈接指令cd /
ln -s /Users/guxuelong/Library/Python/3.7/bin/aws /usr/local/bin/aws
驗證aws --version
四、上傳文件
第一步修改默認配置:aws configure 依次設置access key、secret key、后面兩個可以不用設置
$ aws configure AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY Default region name [None]: us-east-2 Default output format [None]: json
第二步上傳查看,注意設置endpoint-ur
列出存儲桶
$ aws s3 ls --endpoint-url=https://xxx.com列出某個存儲桶中的內容
$ aws s3 ls s3://my-bucket --endpoint-url=https://xxx.com上傳文件到s3存儲桶
$ aws s3 cp my-file s3://my-bucket/my-folder --endpoint-url=https://xxx.com
