Skip to content

Commit

Permalink
Merge pull request #19 from lasanthaS/master
Browse files Browse the repository at this point in the history
Fix docs for metadata and fixes
  • Loading branch information
lasanthaS authored Feb 17, 2023
2 parents 0621f51 + cd15204 commit 0d16ad8
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 2 deletions.
45 changes: 43 additions & 2 deletions docs/blobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ This section provides more information on each of the operations.

#### Uploads a blob file into the storage

The uploadBlob operation uploads a Blob file into the storage.
The uploadBlob operation uploads a Blob file into the storage.

##### To upload a file as a blob

**uploadBlob**
```xml
Expand All @@ -28,6 +30,7 @@ The uploadBlob operation uploads a Blob file into the storage.
<fileName>{$ctx:fileName}</fileName>
<filePath>{$ctx:filePath}</filePath>
<blobContentType>{$ctx:fileContentType}</blobContentType>
<metadata>{$ctx:metadata}</metadata>
</msazurestorage.uploadBlob>
```

Expand All @@ -36,6 +39,42 @@ The uploadBlob operation uploads a Blob file into the storage.
* fileName: The name of the file.
* filePath: The path to a local file to be uploaded.
* blobContentType: The Content-type of the file to be uploaded
* metadata: A JSON formatted metadata string (optional) (ex: `{"meta1": "val1", "meta2": 2, "meta3": "val3"}`)

**Sample request**

Given below is a sample request for the uploadBlob operation.

```json
{
"accountName": "test",
"accountKey": "=gCetnaQlvsXQG4PnlXxxxxXXXXsW37DsDKw5rnCg==",
"containerName": "sales",
"fileName": "sample.txt",
"filePath": "/home/user/Pictures/a.txt",
"metadata": "{'meta1': 'val1', 'meta2': 'val2'}"
}
```

##### To upload a text content as a blob

**uploadBlob**
```xml
<msazurestorage.uploadBlob>
<containerName>{$ctx:containerName}</containerName>
<fileName>{$ctx:fileName}</fileName>
<textContent>{$ctx:payload}</textContent>
<blobContentType>{$ctx:fileContentType}</blobContentType>
<metadata>{$ctx:metadata}</metadata>
</msazurestorage.uploadBlob>
```

**Properties**
* containerName: The name of the container.
* fileName: The name of the file.
* textContent: The text content to be upload as a blob.
* blobContentType: The Content-type of the file to be uploaded
* metadata: A JSON formatted metadata string (optional) (ex: `{"meta1": "val1", "meta2": 2, "meta3": "val3"}`)

**Sample request**

Expand All @@ -47,7 +86,9 @@ Given below is a sample request for the uploadBlob operation.
"accountKey": "=gCetnaQlvsXQG4PnlXxxxxXXXXsW37DsDKw5rnCg==",
"containerName": "sales",
"fileName": "sample.txt",
"filePath": "/home/user/Pictures/a.txt"
"textContent": "Hello, world",
"blobContentType": "text/plain",
"metadata": "{'meta1': 'val1', 'meta2': 'val2'}"
}
```

Expand Down
112 changes: 112 additions & 0 deletions docs/metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Working with Metadata in Microsoft Azure Storage

[[ Overview ]](#overview) [[ Operation details ]](#operation-details) [[ Sample configuration ]](#sample-configuration)

### Overview

The following operations allow you to work with Blob metadata. Click an operation name to learn how to use it.
For a sample proxy service that illustrates how to work with Blob metadata, see [Sample configuration](#sample-configuration).

| Operation | Description |
| ------------- |-------------|
| [uploadMetadata](#uploads-metadata-into-the-storage) | Uploads metadata of a specific blob into the storage. |
| [listMetadata](#retrieves-all-metadata-of-a-blob) | Retrieves all the metadata of a specific blob. |

### Operation details

This section provides more information on each of the operations.

#### Uploads metadata into the storage

**uploadMetadata**
```xml
<msazurestorage.uploadMetadata>
<containerName>{$ctx:containerName}</containerName>
<fileName>{$ctx:fileName}</fileName>
<metadata>{$ctx:payload}</metadata>
</msazurestorage.uploadMetadata>
```

**Properties**
* containerName: The name of the container.
* fileName: The name of the file.
* metadata: A JSON formatted metadata (ex: `{"metadata": {"meta1": "val1", "meta2": 2, "meta3": "val3"}}`)

**Sample request**

Given below is a sample request for the uploadBlob operation.

```json
{
"accountName": "test",
"accountKey": "=gCetnaQlvsXQG4PnlXxxxxXXXXsW37DsDKw5rnCg==",
"containerName": "sales",
"fileName": "sample.txt",
"metadata": "{'metadata': {'meta1': 'val1', 'meta2': 'val2'}}"
}
```

#### Retrieves all metadata of a blob

**uploadMetadata**
```xml
<msazurestorage.listMetadata>
<containerName>{$ctx:containerName}</containerName>
<fileName>{$ctx:fileName}</fileName>
</msazurestorage.listMetadata>
```

**Properties**
* containerName: The name of the container.
* fileName: The name of the file.

**Sample request**

Given below is a sample request for the uploadBlob operation.

```json
{
"accountName": "test",
"accountKey": "=gCetnaQlvsXQG4PnlXxxxxXXXXsW37DsDKw5rnCg==",
"containerName": "sales",
"fileName": "sample.txt"
}
```

**Related Microsoft Azure Storage documentation**

[https://docs.microsoft.com/en-us/azure/storage/blobs/storage-java-how-to-use-blob-storage](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-java-how-to-use-blob-storage)


#### Sample configuration

Given below is a sample proxy service that illustrates how to connect to Microsoft Azure Storage with the init operation and use the listBlobs operation. You can find the sample request for this proxy in the listBlobs sample request.

**Sample Proxy**
```xml
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="listBlobs" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence onError="faultHandlerSeq">
<property name="accountName" expression="json-eval($.accountName)"/>
<property name="accountKey" expression="json-eval($.accountKey)"/>
<property name="containerName" expression="json-eval($.containerName)"/>
<property name="fileName" expression="json-eval($.fileName)"/>
<msazurestorage.init>
<accountName>{$ctx:accountName}</accountName>
<accountKey>{$ctx:accountKey}</accountKey>
</msazurestorage.init>
<msazurestorage.listMetadata>
<containerName>{$ctx:containerName}</containerName>
<fileName>{$ctx:fileName}</fileName>
</msazurestorage.listMetadata>
<respond/>
</inSequence>
<outSequence>
<log/>
<send/>
</outSequence>
</target>
<description/>
</proxy>
```

0 comments on commit 0d16ad8

Please sign in to comment.