☁ How to upload a file to bucket with bash codes using Obsutil ❓
Introduction
Hi everyone 👋😊 , in this article I will show you upload a file to bucket with bash codes using Obsutil. obsutil is a command line tool on Huawei Cloud. I wish you enjoyable reading ❗🤗☕🍫
Obsutil is a command line tool for accessing and managing OBS on Huawei Cloud. You can use this tool to perform common configurations on OBS, such as creating buckets, uploading and downloading files/folders, and deleting files/folders. If you are familiar with command line interface (CLI), obsutil is a good choice for batch processing and automated tasks. obsutil is compatible with the Windows, Linux, and macOS operating systems (OSs).
- Buy an ECS (Linux for Demo)
You can access the command prompt for ECS via the Huawei Cloud GUI by clicking Remote Login.
After you enter the username and password, you can access the virtual machine.
2. Run obsutil Codes
· wget -c https://obs-community-intl.obs.ap-southeast-1.myhuaweicloud.com/obsutil/current/
obsutil_linux_amd64.tar.gz
· tar xvfz obsutil_linux_amd64.tar.gz
· chmod 0755 obsutil_linux_amd64_5.4.11/obsutil
First of all, we download our Obsutil application.
Then we make this application file openable.
Once this file is opened, we use the chmod command to make the application executable.
We copy Obsutil under /usr/sbin/. Because of this, obsutil can be opened from any path.
- cp obsutil_linux_amd64_5.4.11/obsutil /usr/sbin/
We need to set the config file for Obsutil. For this, credentials such as AK/SK are required.
- obsutil config -i=AK -k=SK -e=obs.tr-west-1.myhuaweicloud.com
3. Getting AK/SK
Step 1 Go to My Credentials
Step 2 My Credentials > Access Keys
Step 3 My Credentials > Access Keys > Create Access Key
You can export your AK/SK information in excel format.
• obsutil ls
You can list all the files in Obsutil.
• ls -al
With this command, the “hidden” files and folders in the folder where we are in obsutil are listed as “Verbose”.
Run the ./obsutil mb obs://bucketname -location= tr-west-1 command to create a bucket named bucket-test in the Istanbul region
./obsutil mb obs://feyza-poc -location=tr-west-1
Create bucket [bucket-test] successfully!
We use this command if we want to upload our file loaded in Obsutil to OBS bucket. Thus, we can quickly send large amounts of data to the OBS bucket with the command prompt.
- obsutil cp FILE NAME obs://BUCKETNAME/
Then, If you check the OBS bucket, you will see your filename. File can be uploaded successfully.
Run the ./obsutil rm obs://bucket-test/test.txt -f command to delete object test.txt from bucket bucket-test
./obsutil rm obs://bucket-test/test.txt -f
Delete object [test.txt] in the bucket [bucket-test] successfully!
Run the ./obsutil rm obs://bucket-test -f command to delete bucket bucket-test
./obsutil rm obs://bucket-test -f
Delete bucket [bucket-test] successfully!
Conclusion 🎉
In this article, I showed you upload a file to bucket with bash codes using Obsutil. We learned that we need to pay attention to the obsutil bash codes and credentials. You can use this tool to perform common configurations on OBS, such as creating buckets, uploading and downloading files/folders, and deleting files/folders. I have shared the points that need attention with you. Don’t forget to follow me on Linkedin too 🤗🙌