Skip to content

Commit d7a16c2

Browse files
authored
Merge pull request #3 from Karm/issues-2
[issues-2] Fixed authentication for CREATE_CONTAINER, implemented WRITE_BLOB, docs...
2 parents 8dca5de + a9ff0a1 commit d7a16c2

File tree

7 files changed

+187
-79
lines changed

7 files changed

+187
-79
lines changed

README.md

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ Storing and reading BLOBs to and from a cloud service.
77
* OpenSSL
88

99
# Releases and Downloads
10-
1110
See [Releases](https://github.com/Karm/mod_cloud_storage/releases)
1211

1312
# Usage
14-
15-
The command line tool is controlled via env variables and command line arguments. Command line arguments take priority and overwrite env variables settings.
13+
The command line tool is controlled via env variables and command line arguments. Command line arguments take priority and overwrite env variables settings. If the action is set to *WRITE_BLOB* and neither *MCS_PATH_TO_FILE* nor *--path_to_file* are specified, the command line tool tries to read from stdin.
1614

1715
## Env variables
1816
```
@@ -37,12 +35,14 @@ MCS_TEST_REGIME=true|false
3735
--blob_store_url
3836
--test_regime
3937
```
40-
41-
*Only LIST_BLOBS and CREATE_CONTAINER are implemented at the moment.*
38+
*Only **LIST_BLOBS**, **CREATE_CONTAINER** and **WRITE_BLOB** are implemented at the moment.*
4239

4340
## Testing and fooling around
44-
* Get your [Azurite container up and running](https://github.com/arafato/azurite#docker-image):
41+
* On Linux, get your [Azurite docker container](https://github.com/arafato/azurite#docker-image) up and running
42+
* On Windows, install [Azure Storage Emulator](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator?toc=%2fazure%2fstorage%2fqueues%2ftoc.json)
43+
* Use either *--test_regime true* parameter or *MCS_TEST_REGIME=true* env var as depicted in the examples below
4544

45+
### Creating a container
4646
```
4747
./mod_cloud_storage \
4848
--action CREATE_CONTAINER \
@@ -52,11 +52,49 @@ MCS_TEST_REGIME=true|false
5252
--blob_store_url 127.0.0.1:10000 \
5353
--test_regime true
5454
```
55+
Note the storage account is always called devstoreaccount1 by definition in all Azure Storage emulator implementations. The same holds for the storage key. Container and blob names are arbitrary.
56+
57+
### Writing a BLOB to the container
58+
```
59+
./mod_cloud_storage \
60+
--action WRITE_BLOB \
61+
--azure_storage_key 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==' \
62+
--azure_storage_account 'devstoreaccount1' \
63+
--azure_container mod-cloud-storage \
64+
--blob_store_url localhost:10000 \
65+
--test_regime true \
66+
--blob_name 'testblob' < /tmp/test
67+
```
68+
Note the tool is reading from stdin via pipe now *...< /tmp/test*. One could use either *MCS_PATH_TO_FILE* env var or *--path_to_file* parameter instead. If all aforementioned is specified, *parameter* takes precedence over *env var* and env var takes precedence over *stdin*.
5569

5670
## Working with real Azure storage
57-
* See Azure Portal and Azure Docs on creating Storage Account
58-
* Copy your access key from your Azure Portal
59-
* set test_regime to false or leave it blank
60-
* set blob_store_url to blob.core.windows.net
61-
* set azure_storage_account to your actual storage account name
62-
* *Do not use a storage account with valuable containers in it. This tool is just a toy.*
71+
* [Create your Azure profile](https://azure.microsoft.com/en-us/free/) if you don't have one.
72+
* Create a Storage account if you don't have one, Name, Resource group, all arbitrary. If you need help with this terminology, read [Azure Storage manual](https://docs.microsoft.com/en-us/azure/storage/common/storage-introduction). In this example, we use new Storage account **karmdelete**.<br>
73+
<a href="docs/img/00-new-storage.gif" target="blank"><img src="docs/img/00-new-storage.gif" width="250" height="250"/></a>
74+
<a href="docs/img/01-new-storage-arbitrary-name.gif" target="blank"><img src="docs/img/01-new-storage-arbitrary-name.gif" width="250" height="250"/></a><br>
75+
* Copy your **Account name** and one of the two **Storage keys**.<br>
76+
<a href="docs/img/02-copy-account-name-and-one-of-storage-keys.gif" target="blank"><img src="docs/img/02-copy-account-name-and-one-of-storage-keys.gif" width="250" height="250"/></a><br>
77+
* You are ready to use the command line tool now. First, create a container called, e.g. **my-first-container**.
78+
```
79+
./mod_cloud_storage \
80+
--action CREATE_CONTAINER \
81+
--azure_storage_key 'YourStorageKey' \
82+
--azure_storage_account karmdelete \
83+
--azure_container my-first-container
84+
```
85+
* Let's create a test file, e.g. ```echo "Silence is golden." > /tmp/test```
86+
* Upload the file as a BLOB called e.g. **testblob** to your container **my-first-container** within your Storage account **karmdelete**.
87+
```
88+
./mod_cloud_storage \
89+
--action WRITE_BLOB \
90+
--azure_storage_key 'YourStorageKey' \
91+
--azure_storage_account karmdelete \
92+
--azure_container my-first-container \
93+
--blob_name 'testblob' \
94+
--path_to_file /tmp/test
95+
```
96+
* One may check the result on Azure Portal, click on Blobs in your Storage account:<br>
97+
<a href="docs/img/03-click-on-blobs.gif" target="blank"><img src="docs/img/03-click-on-blobs.gif" width="250" height="250"/></a>
98+
<a href="docs/img/04-testblob-in-container-created.gif" target="blank"><img src="docs/img/04-testblob-in-container-created.gif" width="250" height="250"/></a><br>
99+
* If you download the blob, it contains 19 bytes "Silence is golden.\n"
100+
* **Do not use a storage account with valuable containers in it. This tool is just a toy.**

docs/img/00-new-storage.gif

53.2 KB
Loading
42.9 KB
Loading
71.4 KB
Loading

docs/img/03-click-on-blobs.gif

68 KB
Loading
45.8 KB
Loading

0 commit comments

Comments
 (0)