package com.wql.codebase.utils;import com.microsoft.azure.storage.blob.*;import com.microsoft.azure.storage.blob.models.ContainerCreateResponse;import com.microsoft.rest.v2.RestException;import com.wql.codebase.pojo.Msg;import io.reactivex.Single;import java.io.File;import java.io.IOException;import java.net.MalformedURLException;import java.net.URL;import java.nio.channels.AsynchronousFileChannel;import java.security.InvalidKeyException;/**
* 功能描述:
*
* @author by lgq
* @create 2019/11/13
*/publicclassMicrosoftOssUtil{
privatestatic ContainerURL containerURL;static{
try{
// Retrieve the credentials and initialize SharedKeyCredentials
String accountName ="manwahcrmapiprd";
String accountKey ="9nqa+nAsDi0MsGpCCGb5gJLZq7wUzcJzhM56r3LnKUEdKi3CS/RCUvaZ0SgvN2lLjyATAinzBqjpEa2ZOumqUQ==";// Create a ServiceURL to call the Blob service. We will also use this to construct the ContainerURL
SharedKeyCredentials creds =newSharedKeyCredentials(accountName, accountKey);// We are using a default pipeline here, you can learn more about it at https://github.com/Azure/azure-storage-java/wiki/Azure-Storage-Java-V10-Overviewfinal ServiceURL serviceURL =newServiceURL(newURL("https://"+ accountName +".blob.core.windows.net"), StorageURL.createPipeline(creds,newPipelineOptions()));// Let's create a container using a blocking call to Azure Storage// If container exists, we'll catch and continue
containerURL = serviceURL.createContainerURL("excel");try{
ContainerCreateResponse response = containerURL.create(null, null, null).blockingGet();
System.out.println("Container Create Response was "+ response.statusCode());}catch(RestException e){
if(((RestException) e).response().statusCode()!=409){
throw e;}else{
System.out.println("quickstart container already exists, resuming...");}}}catch(InvalidKeyException e){
System.out.println("Invalid Storage account name/key provided");}catch(MalformedURLException e){
System.out.println("Invalid URI provided");}catch(RestException e){
System.out.println("Service