<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      【Azure Storage Account】Java Code訪問(wèn)Storage Account File Share的上傳和下載代碼示例

      問(wèn)題描述

      使用Azure Storage Account 的File Share,如何通過(guò)Java 代碼來(lái)下載、上傳文件呢?

       

      問(wèn)題解答

      參考Github中Azure File Share代碼介紹( https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/storage/azure-storage-file-share#azure-file-share-client-library-for-java  )。可以使用 azure-storage-file-share 來(lái)實(shí)現(xiàn)上傳下載功能。

      第一步:引入 azure-storage-file-share JDK

       <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-storage-file-share</artifactId>
        <version>12.28.0-beta.1</version>
      </dependency>

      第二步:根據(jù) Storage Account的Connection String和File Share Endpoint創(chuàng)建 ShareDirectoryClient  或 ShareFileClient 對(duì)象

      第三步:調(diào)用 upload() 或 downloadToFile() 上傳/下載文件

       

      完整的示例代碼如下:

      package com.blobs.quickstart;
      
      /**
       * Azure blob storage v12 SDK quickstart
       */ 
      
      import java.io.ByteArrayInputStream;
      import java.io.IOException;
      import java.io.InputStream;
      import java.nio.charset.StandardCharsets;
      
      import com.azure.storage.file.share.ShareDirectoryClient;
      import com.azure.storage.file.share.ShareFileClient;
      import com.azure.storage.file.share.ShareFileClientBuilder;
      
      public class App
      {
          public static void main( String[] args ) throws IOException
          {
               
              System.out.println("Azure file share\n");
              
              final String ACCOUNT_NAME = "";
              final String CONNECTION_STRING = "";
              final String SHARE_NAME = "";
              final String DIRECTORY_PATH = "test";
              final String FILE_NAME = "code.txt";
      
              String fileURL = String.format("https://%s.file.core.chinacloudapi.cn", ACCOUNT_NAME);
              ShareDirectoryClient directoryClient = new ShareFileClientBuilder()
                  .connectionString(CONNECTION_STRING)
                  .endpoint(fileURL)
                  .shareName(SHARE_NAME)
                  .resourcePath(DIRECTORY_PATH)
                  .buildDirectoryClient();
              //Upload file
              String fileName = "testfile1.txt";
              long maxSize = 1024;
              ShareFileClient fclient = directoryClient.createFile(fileName, maxSize);
      
              String uploadText = "Hello, World! This is a test file for Azure file share.\n";
              InputStream data = new ByteArrayInputStream(uploadText.getBytes(StandardCharsets.UTF_8));
              fclient.upload(data, uploadText.length());
      
              //Download file
              ShareFileClient fileClient= new ShareFileClientBuilder()
                  .connectionString(CONNECTION_STRING)
                  .endpoint(fileURL)
                  .shareName(SHARE_NAME)
                  .resourcePath(DIRECTORY_PATH + "/" + FILE_NAME)
                  .buildFileClient();
      
              fileClient.downloadToFile("downloaded_"+java.util.UUID.randomUUID() + "_" + FILE_NAME);
      
              System.out.println("Done");
          }
      }

      完整的POM.xml

      <?xml version="1.0" encoding="UTF-8"?>
      
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
      
        <groupId>com.blobs.quickstart</groupId>
        <artifactId>blob-quickstart-v12</artifactId>
        <version>1.0-SNAPSHOT</version>
      
        <name>blob-quickstart-v12</name>
        <!-- FIXME change it to the project's website -->
        <url>http://www.example.com</url>
      
        <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <maven.compiler.source>1.7</maven.compiler.source>
          <maven.compiler.target>1.7</maven.compiler.target>
        </properties>
      
        <dependencies>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
          </dependency>
       <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-storage-file-share</artifactId>
        <version>12.28.0-beta.1</version>
      </dependency>
          <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.25</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        </dependencies>
      
        <build>
          <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
            <plugins>
              <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
              <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
              </plugin>
              <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
              <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
              </plugin>
              <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
              </plugin>
              <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
              </plugin>
              <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
              </plugin>
              <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
              </plugin>
              <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
              </plugin>
              <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
              <plugin>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.7.1</version>
              </plugin>
              <plugin>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.0.0</version>
              </plugin>
            </plugins>
          </pluginManagement>
        </build>
      </project>

      測(cè)試結(jié)果:

      image 

      參考資料

      posted @ 2025-10-22 21:10  路邊兩盞燈  閱讀(5)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 亚洲免费观看一区二区三区| 国产成人精品永久免费视频| 狠狠五月深爱婷婷网| 科技| 中文字幕日韩一区二区三区不卡| 亚洲人妻系列中文字幕| 亚洲午夜性猛春交xxxx| 日本黄页网站免费观看| 97国产露脸精品国产麻豆| 高清自拍亚洲精品二区| 无码AV中文字幕久久专区 | 精品久久久久久无码不卡| 亚洲欧美精品一中文字幕| 国产黄色三级三级看三级| 熟女系列丰满熟妇AV| 偷拍视频一区二区三区四区| 亚洲中文字幕无码中文字| 国产又爽又大又黄a片| 少妇人妻偷人精品无码视频新浪| 中文字幕亚洲精品乱码| AV在线亚洲欧洲日产一区二区| 中文字幕无线码免费人妻| 国产91精品调教在线播放| 久久精品国产亚洲av天海翼| 亚洲色偷拍区另类无码专区 | 不卡无码人妻一区三区音频| 国产av永久无码天堂影院| 国产成a人亚洲精v品无码性色| av无码精品一区二区三区宅噜噜| 国产亚洲精品aaaa片app| 亚洲一区二区三区人妻天堂 | 国产福利酱国产一区二区| 人妻无码∧V一区二区| 亚洲小说乱欧美另类| av在线中文字幕不卡电影网| 久久亚洲精品天天综合网| 国产边打电话边被躁视频| 91麻豆视频国产一区二区| 国产成人精品2021欧美日韩| av一区二区中文字幕| 麻豆国产成人AV在线播放|