Whatever message this page gives is out now! Go check it out!
omponent {
this.name ="AzureblobTest"
this.serialization.preservecaseforstructkey=true
this.enableNullSupport=true
void function onApplicationStart(){
application.blobCred = {
"vendorName" : "AZURE",
"connectionString" : "xxxxxxxxxxx"
}
application.blobConf = {
"serviceName" : "AZURE_BLOB"
}
}
}blobObject = getCloudService(application.blobCred, application.blobConf)<cfscript>
// define the credential and the configuration aliases in the ColdFusion Admin
blobObject=getCloudService("blobCred","blobConf")
// code below.
...........
</cfscript><cfscript>
blobCred = {
"vendorName" : "AZURE",
"connectionString" : "xxxxxx"
}
blobConf = {
"serviceName" : "AZURE_BLOB",
"options" : {
"absorbConditionalErrorsOnRetry" : true/false,
"concurrentRequestCount" : 5,
"useTransactionalContentMD5" : true/false,
"storeBlobContentMD5" : true/false,
"disableContentMD5Validation": true/fasle,
"singleBlobPutThresholdInBytes" : 12345,
"skipEtagLocking" : true/false,
"retryPolicyFactory": {
"retryPolicyType" : "EXPONENTIAL" | "LINEAR" | "NONE",
"deltaBackoffIntervalInMs" : 12,
"maxAttempts" : 3,
"resolvedMinBackoff" : 1
},
"locationMode" : "PRIMARY_ONLY" | "PRIMARY_THEN_SECONDARY" | "SECONDARY_ONLY" | "SECONDARY_THEN_PRIMARY",
"maximumExecutionTimeInMs" : 2,
"timeoutIntervalInMs" : 1
}
}
</cfscript><cfscript>
// Using config alias and struct for service credentials
// blob credentials
blobCreds={
"vendorName" : "AZURE",
"connectionString" : "xxxxxx"
}
blobObject= getCloudService(blobCreds, "blobConf")
// code below
.....................................
</cfscript><cfscript>
// Using Structs for both cloud credential and config
blobCred = {
"vendorName" : "AZURE",
"connectionString" : "xxxxxx"
}
blobConf = {
"serviceName" : "AZURE_BLOB",
"options" : {
"absorbConditionalErrorsOnRetry" : true/false,
"concurrentRequestCount" : 5,
"useTransactionalContentMD5" : true/false,
"storeBlobContentMD5" : true/false,
"disableContentMD5Validation": true/fasle,
"singleBlobPutThresholdInBytes" : 12345,
"skipEtagLocking" : true/false,
"retryPolicyFactory": {
"retryPolicyType" : "EXPONENTIAL" | "LINEAR" | "NONE",
"deltaBackoffIntervalInMs" : 12,
"maxAttempts" : 3,
"resolvedMinBackoff" : 1
},
"locationMode" : "PRIMARY_ONLY" | "PRIMARY_THEN_SECONDARY" | "SECONDARY_ONLY" | "SECONDARY_THEN_PRIMARY",
"maximumExecutionTimeInMs" : 2,
"timeoutIntervalInMs" : 1
}
}
blob = getCloudService(blobCred, blobConf )
// code below
...................................................................
</cfscript><cfscript>
// Create an object of administrator component and call the login method
adminObj = createObject("component","cfide.adminapi.administrator")
adminObj.login("admin")
// Create an object of cloud component
cloudObj = createObject("component","cfide.adminapi.cloud")
// define credentials struct
credentialStruct={
"vendorName" : "AZURE",
"connectionString" : "xxxxxx"
}
// add credential credentialStruct
try{
cloudObj.addCredential(credentialStruct)
writeOutput("Credentials added successfully")
}
catch(any e){
writeDump(e)
}
</cfscript><cfscript>
// Create an object of administrator component and call the login method
adminObj = createObject("component","cfide.adminapi.administrator")
adminObj.login("admin")
// Create an object of cloud component
cloudObj = createObject("component","cfide.adminapi.cloud")
// define configuration struct
configStruct={
""serviceName" : "AZURE_BLOB",
"options" : {
"absorbConditionalErrorsOnRetry" : true/false,
"concurrentRequestCount" : 5,
"useTransactionalContentMD5" : true/false,
"storeBlobContentMD5" : true/false,
"disableContentMD5Validation": true/fasle,
"singleBlobPutThresholdInBytes" : 12345,
"skipEtagLocking" : true/false,
"retryPolicyFactory": {
"retryPolicyType" : "EXPONENTIAL" | "LINEAR" | "NONE",
"deltaBackoffIntervalInMs" : 12,
"maxAttempts" : 3,
"resolvedMinBackoff" : 1
},
"locationMode" : "PRIMARY_ONLY" | "PRIMARY_THEN_SECONDARY" | "SECONDARY_ONLY" | "SECONDARY_THEN_PRIMARY",
"maximumExecutionTimeInMs" : 2,
"timeoutIntervalInMs" : 1
}
}
// add config configStruct
try{
cloudObj.addServiceConfig(configStruct)
writeOutput("Configuration service added successfully")
}
catch(any e){
writeDump(e)
}
</cfscript>root(rootName, createIfNotExists)Parameter | Description | Required |
rootName | The name of the root to be created. | Yes |
createIfNotExists | True or False. If the root doesn't exist, it gets created. | No |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create a root
try{
storageService.root("root014","false") // createIfNotExists=FALSE
writeOutput("Root created successfully")
}
catch(any e){
writeOutput("Unable to create root")
}
</cfscript>createRoot(parameterStruct)Parameter | Description | Required |
containerName | The name of the root to be created. | Yes |
publicAccesstype | The parameter publicAccessType defines the level at which the access will be granted. This parameter can accept one of the three values:
| No |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create a root object
createRequest= {
"containerName" : "root111",
"publicAccessType" :"BLOB"
}
try{
storageService.createcontainer(createRequest)
writeOutput("Root created successfully")
}
catch(any e){
writeDump(e)
}
</cfscript>listAll(parameterStruct)Parameter | Description | Required |
prefix | Returns only those blobs whose names begin with the specified prefix. | No |
isFlatList | True or False. | No |
listingDetails | Specify one or more values to include in the response:
| No |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// list all blobs
blobList=storageService.listAll()
writeDump(blobList)
</cfscript>delete(parameterStruct)Parameter | Description | Required |
key | The name of the blob to delete. | Yes |
deleteSnapshotsOption | Specify the blob snapshot to delete. Valid values are:
| No |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create a root
try{
storageService.root("root014","false") // createIfNotExists=FALSE
writeOutput("Root created successfully")
}
catch(any e){
writeOutput("Unable to create root")
}
rootArray=storageService.listAll()
writedump(rootArray[1])
// delete the root
try{
storageService.delete(rootArray[1].name)
writeOutput("Root deleted successfully")
}
catch(any e){
writeOutput("Unable to delete root")
}
</cfscript>uploadFile(parameterStruct)Properties | Description | Required |
key | The name of the file. | Yes |
srcFile | The path of the file to be uploaded. | Yes |
accessCondition | An AccessCondition object that represents the condition that must be met in order for the request to proceed. Valid values are:
| No |
context | Represents the context of the current operation. | No |
options | Specifies additional options for the request. If null, default options are applied to the request. | No |
properties |
| No |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create container struct
createRequest= {
"containerName" : "container3",
"publicAccessType" :"BLOB"
}
rootObj=storageService.createcontainer(createRequest)
// An accessCondition object that represents the condition that must be met in order for the request to proceed.
uploadStruct = {
"blobName" : "blob003",
"srcFile" : "#ExpandPath('./')#/file.txt"
}
try {
uploadResponse=rootObj.uploadFile(uploadStruct)
writeOutput("File uploaded successfully")
writeDump(uploadResponse)
}
catch(any e){
writeDump(e)
}
</cfscript><cfscript>
storageService1 = getcloudService(blobCred, blobConf);
rootObj = storageService1.container("root-object12",true);
uploadStruct = {
"blobName" : "key",
"srcFile" : "sample.jpg",
"properties" : {
"contenttype": "image/jpeg"
"contentlanguage": "English"
}
}
uploadResponse=rootObj.uploadFile(uploadStruct)
</cfscript>downloadToFile(parameterStruct)Parameter | Description | Required |
destinationFile | The path where you want to download the file. | Yes |
key | The key associated with the container. | Yes |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// upload a File
uploadStruct = {
"key" : "key001",
"srcFile" : "#ExpandPath('./')#/file.txt"
}
try {
rootObj=storageService.root("root015","true") // createIfNotExists=FALSE
uploadResponse=rootObj.uploadFile(uploadStruct)
writeOutput("File uploaded successfully")
// writeDump(uploadResponse)
}
catch(any e){
writeOutput("File upload failed")
}
// download the file
downloadStruct={
"key": "key001",
"destinationFile": "file.txt"
}
try{
downloadResponse=rootObj.downloadToFile(downloadStruct)
writeOutput("File downloaded successfully")
}
catch (any e){
writedump(e)
}
</cfscript>copy(paramerStruct)Parameter | Description | Required |
source | The source blob. | Yes |
sourceVersion | The version with the blob was uploaded. | No |
sourceAccessCondition | Represents a set of access conditions to be used for operations against the storage services. | No |
storageClass | Valid values are:
| No |
key | The key associated with the blob. | Yes |
<cfscript>
storageService1 = getCloudService(application.blobCred, application.blobConf)
containerList = storageService1.listAll()
// writeDump(containerList)
object1="container-object1"
containerobject = storageService1.container("#object1#",true);
containerList = storageService1.listAll()
// writeDump(containerList)
FileWrite("#ExpandPath('./')#file.txt","this test copy with access condition and storage classes");
src = "file.txt"
blobName = "A/B/blob1"
uploadRequest = {
"srcFile" : src,
"blobName" : blobName
}
uploadResponse = containerobject.uploadFile(uploadRequest);
containerList = containerobject.listAll()
// writeDump(containerList)
// copy blob object
copyRequest = {
"source" : "container-object1/A/B/blob1",
"storageClass" : "HOT",
"blobName" : "C/D/blob2" // destination blob
}
copyResponse = containerobject.copy(copyRequest);
containerList = containerobject.listAll()
writeDump(copyResponse)
</cfscript>uploadDirectory(parameterStruct)Parameter | Description | Required |
prefix | Select only those directories that begin with the specified prefix. | Yes |
srcDirectory | The location of the directory to upload. | Yes |
uploadNestedDirectory | True or False. Specify if you want to include sub-directories inside the main folder. | No |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
object1="root-object1"
uploadRequest = {
"prefix" : "prefix",
"srcDirectory" : "DirLocation",
"uploadNestedDirectory":true
}
root = storageService.container("#object1#",true);
uploadResponse = root.uploadDirectory(uploadRequest); writeDump(uploadResponse)
</cfscript>parallelUploadFile(parameterStruct)Parameter | Description | Required |
key | The key associated with the object that you want to upload. | Yes |
srcFile | The path of the file to be uploaded. | Yes |
accessCondition | An AccessCondition object that represents the condition that must be met in order for the request to proceed. Valid values are:
| No |
context | Represents the context of the current operation. | No |
options | Specifies additional options for the request. If null, default options are applied to the request. Struct containing the following:
| No |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
object1="root-new"
Dirpath=#ExpandPath( ".")#&"/"
rootObject = storageService.root("#object1#",true)
FileWrite("#Dirpath#uploadfile.txt","This txt file is used to upload and download functionality for azure blob storage.")
src = "uploadfile.txt"
key = "key1"
uploadRequest = {
"srcFile" : src,
"key" : key,
"options": {"timeoutIntervalInMs":2000}
}
try{
uploadResponse = rootObject.parallelUploadFile(uploadRequest)
writeOutput("Successfully uploaded file parallelly")
writeDump(uploadResponse)
}
catch(any e){
writeDump(e)
}
</cfscript>parallelDownloadFile(parameterStruct)Parameter | Description | Required |
destinationFile | The name of the file to be downloaded. | Yes |
filePath | The location of the destination file. | Yes |
key | The key associated with the object that you want to upload. | Yes |
srcFile | The path of the file to be uploaded. | Yes |
accessCondition | An AccessCondition object that represents the condition that must be met in order for the request to proceed. Valid values are:
| No |
context | Represents the context of the current operation. | No |
options | Specifies additional options for the request. If null, default options are applied to the request. Struct containing the following:
| No |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
object1="root-download"
Dirpath=#ExpandPath( ".")#&"/"
rootObject = storageService.root("#object1#",true)
FileWrite("#Dirpath#uploadfile.txt","This txt file is used to upload and download functionality for azure blob storage.")
src = "uploadfile.txt"
key = "key1"
uploadRequest = {
"srcFile" : src,
"key" : key
}
// upload file
uploadResponse = rootObject.uploadFile(uploadRequest)
// download the same file that you have uploaded and check the content
FileWrite("#Dirpath#download.txt","");
destination = "download.txt"
downloadRequest = {
"destinationFile" : destination,
"key" : key,
"options": {"timeoutIntervalInMs":2000}
}
try{
downloadResponse = rootObject.parallelDownloadFile(downloadRequest)
writeOutput("Successfully downloaded file parallelly")
writeDump(downloadResponse)
}
catch (any e){
writeDump(e)
}
</cfscript>uploadObject(parameterStruct)Parameter | Description | Required |
object | The ColdFusion object to upload. | Yes |
blobName | The name of theblob where you'd upload the object to. | Yes |
type | Object type- json. | No |
options | Specifies additional options for the request. If null, default options are applied to the request. Struct containing the following:
| No |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
rootObject = storageService.root("root-upload",true)
// define upload struct
uploadRequestsstruct ={
"object" : "test string for encryption",
"blobName" : "key001",
"type" :"json",
"options":{
"maximumExecutionTimeInMs" : 1000
}
}
try{
uploadResponse=rootObject.uploadObject(uploadRequestsstruct)
writeOutput("Object uploaded successfully")
writeDump(uploadResponse)
}
catch(any e){
writeDump(e)
}
</cfscript>downloadObject(parameterStruct)Parameter | Description | Required |
key | The key with which the object was uploaded. | Yes |
type | Type of the ColdFusion object- json | Yes |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
rootObject = storageService.root("root-download",true)
// define upload struct
uploadRequestsstruct ={
"object" : "test string for encryption",
"blobName" : "key001",
"type" :"json",
"options":{
"maximumExecutionTimeInMs" : 1000
}
}
// upload object
rootObject.uploadObject(uploadRequestsstruct)
// define download struct
downloadObjectStruct = {
"blobName" : "key001",
"type" :"json"
}
try{
downloadResponse=rootObject.downloadObject(downloadObjectStruct)
writeOutput("Downloaded the object successfully")
writeDump(downloadResponse)
}
catch(any e){
writeDump(e)
}
</cfscript>createSnapshot(parameterStruct)Parameter | Description | Required |
blobName | The name of the blob whose snapshot you want to create. | Yes |
keyName | The key associated with the blob. | Yes |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create container
container = storageService.container("con001",true)
src = "#ExpandPath('./')#file.txt"
//writedump(src)
blobname = "Version-1"
// upload a file into the blob
uploadRequest = {
"srcFile" : src,
"blobName" : blobname
}
uploadResponse = container.uploadFile(uploadRequest)
//writeDump(uploadResponse)
// Create snapshot
// Create snapshot struct
versionRequest = {
"blobName" : "Version-1"
}
snapshot1 = container.Createsnapshot(versionRequest);
snapshot2 = container.Createsnapshot(versionRequest);
writeDump(snapshot1)
writeDump(snapshot2)
</cfscript><cfscript>
storageService1 = getCloudService(application.blobCred, application.blobConf)
rootList = storageService1.listAll()
for (i=1;i LTE ArrayLen(rootList);i=i+1)
{
if( (i GT 0 ) and (rootList[i].name Neq "rootpoc") ){
storageService1.delete(rootList[i].name)}
}
sleep(35000)
rootobject = storageService1.container("#object1#",true);
rootList = storageService1.listAll()
FileWrite("#Dirpath#uploadfile.txt","this test copy with access condition and storage classes");
src = "uploadfile.txt"
blobName = "A/B/key1"
uploadRequest = {
"srcFile" : src,
"blobName" : blobName
}
uploadResponse = rootobject.uploadFile(uploadRequest);
rootList = rootobject.listAll()
copyRequest = {
"source" : "root-object1/A/B/key1",
"storageClass" : "HOT",
"blobName" : "C/D/Key2"
}
copyResponse = rootobject.copy(copyRequest);
rootList = rootobject.listAll()
for (i=1;i LTE ArrayLen(rootList.response);i=i+1)
{
if(rootList.response[i].blobName eq "C/D/Key2"){
writeoutput(rootList.response[i].properties.standardBlobTier & " ")}
}
writeoutput(copyResponse.status)
</cfscript>createVersion(parameterStruct)Parameter | Description | Required |
blobName | The name of the blob whose snapshot you want to create. | Yes |
keyName | The key associated with the blob. | Yes |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
object1="root-object1"
FileWrite("#ExpandPath('./')#file.txt","this test copy with access condition and storage classes");
rootobject = storageService.root("#object1#",true);
src = "file.txt"
key = "Version-1"
uploadRequest = {
"srcFile" : src,
"key" : key
}
uploadResponse = rootobject.uploadFile(uploadRequest);
writeDump(uploadResponse)
versionRequest = {
"key" : "Version-1"
}
Version1 = rootobject.createversion(versionRequest);
Version2 = rootobject.createversion(versionRequest);
writeDump(Version1)
writeDump(Version2)
</cfscript>putPolicy(parameterStruct)Parameter | Description | Required |
permissions | Specifies the array of possible permissions for a shared access policy. Values are:
| No |
sharedAccessStartTime | Specifies the time when access is granted. | No |
sharedAccessExpiryTime | Specifies the time when the access expires. | No |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create container
container = storageService.container("con002",true)
// Uploads the container's permissions using the specified request options and operation context.
// policy struct
policyStruct = {
"publicAccessType" : "OFF", //BLOB,CONTAINER
"sharedAccessPolicies" : {
"policyName1" : {
"permissions" : ["READ", "ADD"],
"sharedAccessExpiryTime" : "31/12/2019",
"sharedAccessStartTime" : "17/12/2019"
},
"policyName2" : {
"permissions" : ["READ", "ADD"],
"sharedAccessExpiryTime" : "31/12/2019",
"sharedAccessStartTime" : "17/12/2019"
}
}
}
putPolicyResponse=container.putPolicy(policyStruct);
writeDump(putPolicyResponse)
getPolicyResponse=container.getPolicies()
writeOutput("<br/>" & "List of all policies")
writeDump(getPolicyResponse)
</cfscript>getPolicies()<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create container
container = storageService.container("con002",true)
// Uploads the container's permissions using the specified request options and operation context.
// policy struct
policyStruct = {
"publicAccessType" : "OFF", //BLOB,CONTAINER
"sharedAccessPolicies" : {
"policyName1" : {
"permissions" : ["READ", "ADD"],
"sharedAccessExpiryTime" : "31/12/2019",
"sharedAccessStartTime" : "17/12/2019"
},
"policyName2" : {
"permissions" : ["READ", "ADD"],
"sharedAccessExpiryTime" : "31/12/2019",
"sharedAccessStartTime" : "17/12/2019"
}
}
}
putPolicyResponse=container.putPolicy(policyStruct);
writeDump(putPolicyResponse)
getPolicyResponse=container.getPolicies()
writeOutput("<br/>" & "List of all policies")
writeDump(getPolicyResponse)
</cfscript>deletePolicies()<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create container
container = storageService.container("con002",true)
// Uploads the container's permissions using the specified request options and operation context.
// policy struct
policyStruct = {
"publicAccessType" : "OFF", //BLOB,CONTAINER
"sharedAccessPolicies" : {
"policyName1" : {
"permissions" : ["READ", "ADD"],
"sharedAccessExpiryTime" : "31/12/2019",
"sharedAccessStartTime" : "17/12/2019"
},
"policyName2" : {
"permissions" : ["READ", "ADD"],
"sharedAccessExpiryTime" : "31/12/2019",
"sharedAccessStartTime" : "17/12/2019"
}
}
}
putPolicyResponse=container.putPolicy(policyStruct);
writeDump(putPolicyResponse)
getPolicyResponse=container.getPolicies()
writeOutput("<br/>" & "List of all policies")
writeDump(getPolicyResponse)
// delete policies
try{
deletePolicyResponse=container.deletePolicies()
writeOutput("Policy deleted successfully")
writeDump(deletePolicyResponse)
}
catch(any e){
writeDump(e)
}
</cfscript>generateSas(parameterStruct)Parameter | Description | Required |
blob | The blob that you want to enforce SAS permissions on. | Yes |
policy | Struct containing the following: permissions: Specifies the array of possible permissions for a shared access policy. Values are:
sharedAccessStartTime: Specifies the time when access is granted. sharedAccessExpiryTime: Specifies the time when the access expires. | Yes |
headers | Struct containing the following:
| No |
<cfscript>
// A shared access signature (SAS) provides secure delegated access to resources in your storage
// account without compromising the security of your data.
// With a SAS, you have granular control over how a client can access your data.
// You can control what resources the client may access, what permissions they have on those resources,
// and how long the SAS is valid, among other parameters.
storageService = getCloudService(application.blobCred, application.blobConf)
object1="root-object1"
root = storageService1.container("#object1#",true)
FileWrite("#ExpandPath('./')#file.txt","Sgt. Pepper's Lonely Hearts Club Band")
src = "file.txt"
blobName = "key1"
uploadRequest = {
"srcFile" : src,
"blobName" : blobName
}
uploadResponse = root.uploadFile(uploadRequest)
expdate= DatePart("d",now())+2;
month= DatePart("m",now())
year= DatePart("yyyy",now())
startdate=DatePart("d",now());
sasRequest ={
"blobName" : "key1",
"policy" : {
"permissions" : ["READ"],
"sharedAccessExpiryTime" : "#month#/#Expdate#/#year#",
"sharedAccessStartTime" : "#month#/#startdate#/#year#"
}
}
sharedAccessSignature = root.generateSas(sasRequest);
writedump(sharedAccessSignature)
</cfscript>acquireLease(parameterStruct)Parameter | Description | Required |
leaseTimeInSeconds | The duration of the lease. | Yes |
proposedLeaseID | The ID of the created lease on the blob. | No |
<cfscript>
// Acquire lease and check lease acquire status.
storageService = getCloudService(application.blobCred, application.blobConf)
object1="root-object1"
root = storageService1.container("#object1#",true);
FileWrite("#ExpandPath('./')#/uploadfile.txt","Coldfusion2020 lease-related operation.");
src = "uploadfile.txt"
blobName = "key1"
uploadRequest = {
"srcFile" : src,
"blobName" : blobName
}
uploadResponse = root.uploadFile(uploadRequest)
acquireLeaseRequest = {
"blobName":blobName,
"leaseDurationInSeconds": 15,
"proposedLeaseId": "lease01"
}
acqLeaseResponse=root.acquireLease(acquireLeaseRequest)
writeDump(acqLeaseResponse)
</cfscript>renewLease(parameterStruct)Parameter | Description | Required |
leaseTimeInSeconds | The lease duration to renew. | Yes |
proposedLeaseID | The ID of the lease. | No |
<cfscript>
// Acquire lease and check lease acquire status.
object1="root-object1"
storageService1 = getCloudService(application.blobCred, application.blobConf)
root = storageService1.container("#object1#",true);
// Acquire lease and check lease acquire status.
Dirpath=#ExpandPath( ".")#&"/"
root = storageService1.container("#object1#",true);
FileWrite("#Dirpath#uploadfile.txt","Coldfusion2020 lease related operation");
src = "uploadfile.txt"
blobName = "key1"
uploadRequest = {
"srcFile" : src,
"blobName" : blobName
}
uploadResponse = root.uploadFile(uploadRequest)
acquireLeaseRequest = {
"blobName":blobName,
"leaseDurationInSeconds": 15,
"proposedLeaseId": "dddddddddddddddddddddddddddddddd"
}
root.acquireLease(acquireLeaseRequest)
// Renew existing lease
sleep(16000)
renewLeaseRequest = {
"blobName":blobName,
"accessCondition" : { "leaseID" :"dddddddddddddddddddddddddddddddd" }
}
renewLeaseResponse=root.renewLease(renewLeaseRequest)
writeDump(renewLeaseResponse)
</cfscript>changeLease(parameterStruct)Parameter | Description | Required |
leaseTimeInSeconds | The lease duration to change. | Yes |
proposedLeaseID | The ID of the lease. | No |
<cfscript>
// Acquire lease and check lease acquire status.
object1="root-object1"
storageService1 = getCloudService(application.blobCred, application.blobConf)
root = storageService1.container("#object1#",true);
// Acquire lease and check lease acquire status.
Dirpath=#ExpandPath( ".")#&"/"
root = storageService1.container("#object1#",true);
FileWrite("#Dirpath#uploadfile.txt","Coldfusion 2020 lease related operation");
src = "uploadfile.txt"
blobName = "key1"
uploadRequest = {
"srcFile" : src,
"blobName" : blobName
}
uploadResponse = root.uploadFile(uploadRequest)
//acquire lease
acquireLeaseRequest = {
"blobName":blobName,
"leaseDurationInSeconds": 15,
"proposedLeaseId": "dddddddddddddddddddddddddddddddd"
}
root.acquireLease(acquireLeaseRequest)
//To change existing lease
changeLeaseRequest = {
"blobName":blobName,
"proposedLeaseId": "ddddddddddddddcccccccccccccccccc",
"accessCondition" : { "leaseID" :"ddddddddddddddddcddddddddddddddd" }
}
changeleaseid=root.changeLease(changeLeaseRequest)
writeDump(changeleaseid)
</cfscript>releaseLease(parameterStruct)Parameter | Description | Required |
blobPath | The path of the blob whose lease has to be renewed. | Yes |
leaseID | The ID of the lease. | No |
<cfscript>
// Acquire lease and check lease acquire status.
object1="root-object1"
storageService1 = getCloudService(application.blobCred, application.blobConf)
root = storageService1.container("#object1#",true);
// Acquire lease.
Dirpath=#ExpandPath( ".")#&"/"
root = storageService1.container("#object1#",true);
FileWrite("#Dirpath#uploadfile.txt","Coldfusion2020 lease related operation");
src = "uploadfile.txt"
blobName = "key1"
uploadRequest = {
"srcFile" : src,
"blobName" : blobName
}
uploadResponse = root.uploadFile(uploadRequest)
acquireLeaseRequest = {
"blobName":blobName,
"leaseDurationInSeconds": 60,
"proposedLeaseId": "dddddddddddddddddddddddddddddddd"
}
root.acquireLease(acquireLeaseRequest)
// Release the existing lease
changeLeaseRequest = {
"blobName":blobName,
"accessCondition" : { "leaseID" :"dddddddddddddddddddddddddddddddd" }
}
releaseResponse=root.releaseLease(changeLeaseRequest)
writeDump(releaseResponse)
</cfscript>breakLease(parameterStruct)Parameter | Description | Required |
blobPath | The path of the blob whose lease has to be terminated. | Yes |
leaseID | The ID of the lease. | No |
<cfscript>
// Acquire lease and check lease acquire status.
object1="root-object1"
storageService1 = getCloudService(application.blobCred, application.blobConf)
root = storageService1.container("#object1#",true);
// Acquire lease.
Dirpath=#ExpandPath( ".")#&"/"
root = storageService1.container("#object1#",true);
FileWrite("#Dirpath#uploadfile.txt","Coldfusion2020 lease related operation");
src = "uploadfile.txt"
blobName = "key1"
uploadRequest = {
"srcFile" : src,
"blobName" : blobName
}
uploadResponse = root.uploadFile(uploadRequest)
acquireLeaseRequest = {
"blobName":blobName,
"leaseDurationInSeconds": 60,
"proposedLeaseId": "dddddddddddddddddddddddddddddddd"
}
root.acquireLease(acquireLeaseRequest)
//To break lease existing lease
breakleaserequest = {
"blobName":blobName,
"accessCondition" : { "leaseID" :"dddddddddddddddddddddddddddddddd" }
}
breakLeaseResponse=root.breakLease(breakleaserequest)
writeDump(breakLeaseResponse)
</cfscript>getKeyPairfromkeystore(parameterStruct)Parameter | Description |
keystore | Location of the keystore or jks file. |
keystorePassword | Password of the jks file. |
keypairPassword | Password of RSA keypair. |
keystoreAlias | Alias name of the jks keystore. |
keyStoreType | Jks or pkcs12. |
<cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
keyPair2 = getKeyPairfromkeystore({
"keystore": ExpandPath("blobkey.p12"),
"keystorePassword": "changeit"
})
// create a root
rootobject = storageService.root("root001",true);
uploadRequestsstruct ={
"object" : "Encryption 001",
"key" : "key001",
"type" :"json",
"options" : {
"encryption":{
"keypair": keyPair2,
"kid": "sample"
}
}
}
uploadResponse = rootobject.uploadObject(uploadRequest=uploadRequestsstruct)
writeDump(uploadResponse)
</cfscript><cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create a root
rootobject = storageService.root("root002",true)
// create jks struct
keyPair2 = getKeyPairfromkeystore({
"keystore": ExpandPath("blobkey.jks"),
"keystorePassword": "changeit",
"keypairPassword": "changeit",
"keystoreAlias": "alias3",
"keyStoreType": "jks"
})
// create upload struct
uploadRequestsstruct ={
"object" : "Object 002",
"key" : "key",
"type" :"json",
"options" : {
"encryption":{ "keypair": keyPair2, "kid": "sample" }}
}
uploadResponse = rootobject.uploadObject(uploadRequest=uploadRequestsstruct)
writeDump(uploadResponse)
</cfscript><cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create keypair struct
keyPair2 = getKeyPairfromkeystore({
"keystore": ExpandPath("blobkey.p12"),
"keystorePassword": "changeit"
})
// create root
rootobject = storageService.root("root003",true);
// upload struct
uploadRequestsstruct ={
"object" : "Test string azureb blob for encryption",
"key" : "key",
"type" :"json",
"options" : {
"encryption":{ "keypair": keyPair2, "kid": "sample" }}
}
uploadResponse = rootobject.uploadObject(uploadRequest=uploadRequestsstruct);
// download struct
downloadStruct = {
"key" : "key",
"type" :"json",
"options" : {"encryption":{ "keypair": keyPair2, "kid": "sample" }}
}
try{
downloadResponse =rootobject.downloadObject(downloadStruct)
if(downloadResponse.object=="Test string azureb blob for encryption" &&
uploadResponse.status=="success" &&
downloadResponse.status=="success")
writeOutput("Object downloaded successfully")
}
catch(any e)
{
writeDump(e)
}
</cfscript><cfscript>
storageService = getCloudService(application.blobCred, application.blobConf)
// create root
rootobject = storageService.root("root004",true)
//create keypair struct
keyPair2 = getKeyPairfromkeystore({
"keystore": ExpandPath("blobkey.jks"),
"keystorePassword": "changeit",
"keypairPassword": "changeit",
"keystoreAlias": "alias3",
"keyStoreType": "jks"
})
// create object upload struct
uploadRequestsstruct ={
"object" : "Test string azureb blob for encryption",
"key" : "key",
"type" :"json",
"options" : {
"encryption":{ "keypair": keyPair2, "kid": "sample" }}
}
uploadResponse = rootobject.uploadObject(uploadRequest=uploadRequestsstruct);
// create object download struct
downloadObject = {
"key" : "key",
"type" :"json",
"options" : {
"encryption":{ "keypair": keyPair2, "kid": "sample" }}
}
try{
downloadResponse =rootobject.downloadObject(downloadObject)
if(
downloadResponse.object=="Test string azureb blob for encryption" &&
uploadResponse.status=="success" &&
downloadResponse.status=="success")
writeOutput("Object downloaded successfully")
}
catch(any e)
{
writeDump(e);
}
</cfscript>blockUpload(parameterStruct)Parameter | Description | Required |
blockId | The ID of the block of blob that you want to upload. | Yes |
blobName | The name of the blob to upload. | Yes |
srcFile | The path of the file to be uploaded. | Yes |
<cfscript>
try{
blobAccount = getcloudService(application.blobCred, application.blobConf);
rootList = blobAccount.listAll()
for (i=1;i LTE ArrayLen(rootList);i=i+1)
{
if( (rootList[i].name eq "testcontainer") ){
blobAccount.delete(rootList[i].name)
sleep(35000)
}
}
root = blobAccount.container("testcontainer", true);
blobname = "Suite.zip"
createPartFileRequest = {
"srcFile":blobname,
"blockSizeInBytes": 102400,
"destinationDirectory": "Destination"
}
respt = root.createPartFiles(createPartFileRequest)
blockIds = ArrayNew(1);
blockIdItr = "ddd"
count=1
for(partFile in respt["partFiles"]) {
bid=""&(1000 + count) //toBase64(URLEncodedFormat("ddd"&count))
structUpload = {
"blockId": bid,
"blobName": blobName,
"srcFile": partFile
}
respt = root.blockUpload(structUpload);
arrayAppend(blockIds, bid)
count=count+1
}
commitBlockList = {
"blockIds": blockIds,
"blobName": blobName
}
respt = root.commitBlockList(commitBlockList);
if(respt.status=="SUCCESS")
writeOutput("Successful upload!")
}
catch(any e)
{
writeDump(e)
}
</cfscript>uploadMetadata(parameterStruct)Parameter | Description | Required |
key | The key associated with the blob. | Yes |
metadata | Struct that contains the following:
| Yes |
<cfscript>
try{
storageService1 = getcloudService(this.blobCred, this.blobConf);
rootList = storageService1.listAll()
for (i=1;i LTE ArrayLen(rootList);i=i+1)
{
if( (i GT 0 )){
storageService1.delete(rootList[i].name)}
}
sleep(35000)
rootobject = storageService1.root("#object1#",true);
FileWrite("#Dirpath#UploadTest.txt","Test1.txt uploaded")
src = "UploadTest.txt"
key = "A/B/Test1"
uploadRequest = {
"srcFile" : src,
"key" : key
}
uploadResponse = rootobject.uploadFile(uploadRequest);
uploadMetadata = {
"key" : "A/B/Test1",
"metadata" : {
"Details" : "Test1.txt uploaded"
}
}
response =rootobject.uploadMetadata(uploadMetadata);
writeoutput(response.status&" ");
blobStruct = {
"prefix" : "",
"isFlatListing" : "true",
"listingDetails" :["METADATA"]
}
rootList = rootobject.listAll(blobStruct)
if(rootList.response[1].metadata["Details"] EQ "Test1.txt uploaded")
{
writeoutput("Uploaded successfully")
}
}
catch(any e)
{
writedump(e);
}
</cfscript>createPartFiles(parameterStruct)<cfscript>
try{
blobAccount = getcloudService(application.blobCred, application.blobConf);
rootList = blobAccount.listAll()
for (i=1;i LTE ArrayLen(rootList);i=i+1)
{
if( (rootList[i].name eq "testcontainer") ){
blobAccount.delete(rootList[i].name)
sleep(35000)
}
}
root = blobAccount.container("testcontainer", true);
blobname = "Suite.zip"
createPartFileRequest = {
"srcFile":blobname,
"blockSizeInBytes": 102400,
"destinationDirectory": "Destination"
}
respt = root.createPartFiles(createPartFileRequest)
blockIds = ArrayNew(1);
blockIdItr = "ddd"
count=1
for(partFile in respt["partFiles"]) {
bid=""&(1000 + count) //toBase64(URLEncodedFormat("ddd"&count))
structUpload = {
"blockId": bid,
"blobName": blobName,
"srcFile": partFile
}
respt = root.blockUpload(structUpload);
arrayAppend(blockIds, bid)
count=count+1
}
commitBlockList = {
"blockIds": blockIds,
"blobName": blobName
}
respt = root.commitBlockList(commitBlockList);
if(respt.status=="SUCCESS")
writeOutput("Successful upload!")
}
catch(any e)
{
writeDump(e)
}
</cfscript>createPartFiles(parameterStruct)<cfscript>
try{
blobAccount = getcloudService(application.blobCred, application.blobConf);
rootList = blobAccount.listAll()
for (i=1;i LTE ArrayLen(rootList);i=i+1)
{
if( (rootList[i].name eq "testcontainer") ){
blobAccount.delete(rootList[i].name)
sleep(35000)
}
}
root = blobAccount.container("testcontainer", true);
blobname = "perfSuite.zip"
createPartFileRequest = {
"srcFile":blobname,
"blockSizeInBytes": 102400,
"destinationDirectory": "Destination"
}
respt = root.createPartFiles(createPartFileRequest)
blockIds = ArrayNew(1);
blockIdItr = "ddd"
count=1
for(partFile in respt["partFiles"]) {
bid=""&(1000 + count) //toBase64(URLEncodedFormat("ddd"&count))
structUpload = {
"blockId": bid,
"blobName": blobName,
"srcFile": partFile
}
respt = root.blockUpload(structUpload);
arrayAppend(blockIds, bid)
count=count+1
}
commitBlockList = {
"blockIds": blockIds,
"blobName": blobName
}
respt = root.commitBlockList(commitBlockList);
if(respt.status=="SUCCESS")
writeOutput("Uploaded")
}
catch(any e)
{
writeDump(e)
}
</cfscript>