• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Python Script to Upload Files to OpenStack Swift (HP Cloud CDN)

By Abhishek Ghosh February 20, 2015 8:28 am Updated on February 20, 2015

Python Script to Upload Files to OpenStack Swift (HP Cloud CDN)

Advertisement

Here is a Simple Python Script to Upload Files to OpenStack Swift, for Our Case HP Cloud CDN. Very easy to use from Mac or Linux Server. This is an expected thing to our regular readers whom are following our previous guides. We wanted to work with only Python Swift Client. That is the only near Error Free Tool so far.

 

What You Need To Know Before Using This Python Script to Upload Files to OpenStack Swift (HP Cloud CDN)

 

You need to read our previous guides :

 

  1. Upload to HP Cloud CDN Using OpenStack Swift Client
  2. WordPress W3TC Setup to Upload Files to HP Cloud CDN Using OpenStack Swift Client 

 

From those guides, you have to find the links to install and configure Python Swift Client. You must have that openrc.sh file imported in your .zshrc or .bashrc file. In other words, swift command must be working.

Advertisement

---

 

Python Script to Upload Files to OpenStack Swift (HP Cloud CDN)

 

It is a very simple file named upload.sh. Upon running the script, it will ask for the path (or file) you want to upload things from and the container name. After the work is done, it will give you the message with time stamp.

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env bash
# –*– coding: utf–8 –*–
#
# Author : Dr. Abhishek Ghosh
# GNU GPL 3.0
# https://thecustomizewindows.com
#
echo “Script to copy source files/directories to OpenStack Swift Storage”
echo “Supply the source file/directory below:”
read target
echo “Supply the Swift Container Name Below:”
read container
echo ” “
swift upload $container $target
finish=date "+%Y-%m-%d-%H-%M-%S"
echo “Upload completed at ${finish}”

Yeah, quite basic; but that basic script was not available. As the bash is set for Python, it will not throw error, at least on OS X. To use it, run :

Vim
1
2
3
4
git clone https://github.com/AbhishekGhosh/OpenStack–Swift–Upload–Script.git
cd OpenStack–Swift–Upload–Script*
chmod +x upload.sh
sh upload.sh
Python Script to Upload Files to OpenStack Swift (HP Cloud CDN)

It will ask “Supply the source file/directory below:”. You will paste/type the full UNIX path like :

Vim
1
/Users/abhishekghosh/Desktop/cdn

and hit the Return / Enter Key. Then it will ask “Supply the container name below:”. You’ll type only the container name, like :

Vim
1
test

and hit the Return / Enter Key. For me, it gave output :

Vim
1
2
3
/Users/abhishekghosh/Desktop/cdn/.DS_Store
/Users/abhishekghosh/Desktop/cdn/OpenShift WordPress Multisite.png
Upload completed at 2015–01–31–02–45–13

You can omit No handlers could be found for logger “keystoneclient.httpclient” error. Thats not our fault.
Easy thing. But that is showing some light towards a plain web based tool, WordPress Plugin and many stuffs. Without sudo it is running. When OS X it is running, it should work fine for Linux, there is no UNIX Wheel Group.

 

Next Steps

 

Adding Meta Data. Most important.
Adding the function to copy static files from directory A to directory B. Then upload.
Adding the Auth System within the script.
Integrating with Original Swift Client.
Adding Colors.
Porting as WordPress Plugin.

Right now, it will crudely copy all. Programmatically it is important. By usage, you might not find very very useful. We will try to execute it via PHP. That will avoid installing the Junks.

The things are reminding me of the Lady who on her off time wrote a punch card to input data to a kind of mechanical machine.

Tagged With cdn file upload python , how to upload file to openstack swift via webpage , paperuri:(b4109fe7a261bc1479953abad1ac89fa) , python script to upload file , python scripting accesing Openstack file
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Python Script to Upload Files to OpenStack Swift (HP Cloud CDN)

  • Deploy OctoPress on OpenStack Swift (HP Cloud)

    Here is How To Deploy OctoPress on OpenStack Swift, Example Given With HP Helion Cloud With Only Python Swift Client & a Custom Shebang Script.

  • OpenStack Swift & HPCloud CDN PHP Bindings : Basics

    Here is the basics of OpenStack Swift & HPCloud CDN PHP Bindings for the WordPress Plugin developers and those who works with PHP based CMS.

  • Upload to IBM Cloud CDN Using OpenStack Swift Client

    Here is How Upload to IBM Cloud CDN Using OpenStack Swift Client. We have a helper Python script for the process. IBM Cloud CDN needs Pay-as-you-go account.

  • Adding Help & Option in Bash Script

    Many New Hobbyist Programmers and Students Write Bash Scripts. Adding Help & Option in Bash Script is Easy. Here is Basic Guide With Example.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy