[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-1f91f5f6-de5b-4521-b074-06ce5e37404d":3,"$fwpoOZ9pSdpqzGeVrwJxKbLp50I_dFwuECp6em7snqhQ":44},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"1f91f5f6-de5b-4521-b074-06ce5e37404d","azure-storage-blob-java","使用 Azure Storage Blob SDK for Java 构建Blob存储应用程序。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-storage-blob-java\ndescription: \"Build blob storage applications using the Azure Storage Blob SDK for Java.\"\nrisk: unknown\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# Azure Storage Blob SDK for Java\n\nBuild blob storage applications using the Azure Storage Blob SDK for Java.\n\n## Installation\n\n```xml\n\u003Cdependency>\n    \u003CgroupId>com.azure\u003C\u002FgroupId>\n    \u003CartifactId>azure-storage-blob\u003C\u002FartifactId>\n    \u003Cversion>12.33.0\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n## Client Creation\n\n### BlobServiceClient\n\n```java\nimport com.azure.storage.blob.BlobServiceClient;\nimport com.azure.storage.blob.BlobServiceClientBuilder;\n\n\u002F\u002F With SAS token\nBlobServiceClient serviceClient = new BlobServiceClientBuilder()\n    .endpoint(\"\u003Cstorage-account-url>\")\n    .sasToken(\"\u003Csas-token>\")\n    .buildClient();\n\n\u002F\u002F With connection string\nBlobServiceClient serviceClient = new BlobServiceClientBuilder()\n    .connectionString(\"\u003Cconnection-string>\")\n    .buildClient();\n```\n\n### With DefaultAzureCredential\n\n```java\nimport com.azure.identity.DefaultAzureCredentialBuilder;\n\nBlobServiceClient serviceClient = new BlobServiceClientBuilder()\n    .endpoint(\"\u003Cstorage-account-url>\")\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .buildClient();\n```\n\n### BlobContainerClient\n\n```java\nimport com.azure.storage.blob.BlobContainerClient;\n\n\u002F\u002F From service client\nBlobContainerClient containerClient = serviceClient.getBlobContainerClient(\"mycontainer\");\n\n\u002F\u002F Direct construction\nBlobContainerClient containerClient = new BlobContainerClientBuilder()\n    .connectionString(\"\u003Cconnection-string>\")\n    .containerName(\"mycontainer\")\n    .buildClient();\n```\n\n### BlobClient\n\n```java\nimport com.azure.storage.blob.BlobClient;\n\n\u002F\u002F From container client\nBlobClient blobClient = containerClient.getBlobClient(\"myblob.txt\");\n\n\u002F\u002F With directory structure\nBlobClient blobClient = containerClient.getBlobClient(\"folder\u002Fsubfolder\u002Fmyblob.txt\");\n\n\u002F\u002F Direct construction\nBlobClient blobClient = new BlobClientBuilder()\n    .connectionString(\"\u003Cconnection-string>\")\n    .containerName(\"mycontainer\")\n    .blobName(\"myblob.txt\")\n    .buildClient();\n```\n\n## Core Patterns\n\n### Create Container\n\n```java\n\u002F\u002F Create container\nserviceClient.createBlobContainer(\"mycontainer\");\n\n\u002F\u002F Create if not exists\nBlobContainerClient container = serviceClient.createBlobContainerIfNotExists(\"mycontainer\");\n\n\u002F\u002F From container client\ncontainerClient.create();\ncontainerClient.createIfNotExists();\n```\n\n### Upload Data\n\n```java\nimport com.azure.core.util.BinaryData;\n\n\u002F\u002F Upload string\nString data = \"Hello, Azure Blob Storage!\";\nblobClient.upload(BinaryData.fromString(data));\n\n\u002F\u002F Upload with overwrite\nblobClient.upload(BinaryData.fromString(data), true);\n```\n\n### Upload from File\n\n```java\nblobClient.uploadFromFile(\"local-file.txt\");\n\n\u002F\u002F With overwrite\nblobClient.uploadFromFile(\"local-file.txt\", true);\n```\n\n### Upload from Stream\n\n```java\nimport com.azure.storage.blob.specialized.BlockBlobClient;\n\nBlockBlobClient blockBlobClient = blobClient.getBlockBlobClient();\n\ntry (ByteArrayInputStream dataStream = new ByteArrayInputStream(data.getBytes())) {\n    blockBlobClient.upload(dataStream, data.length());\n}\n```\n\n### Upload with Options\n\n```java\nimport com.azure.storage.blob.models.BlobHttpHeaders;\nimport com.azure.storage.blob.options.BlobParallelUploadOptions;\n\nBlobHttpHeaders headers = new BlobHttpHeaders()\n    .setContentType(\"text\u002Fplain\")\n    .setCacheControl(\"max-age=3600\");\n\nMap\u003CString, String> metadata = Map.of(\"author\", \"john\", \"version\", \"1.0\");\n\ntry (InputStream stream = new FileInputStream(\"large-file.bin\")) {\n    BlobParallelUploadOptions options = new BlobParallelUploadOptions(stream)\n        .setHeaders(headers)\n        .setMetadata(metadata);\n    \n    blobClient.uploadWithResponse(options, null, Context.NONE);\n}\n```\n\n### Upload if Not Exists\n\n```java\nimport com.azure.storage.blob.models.BlobRequestConditions;\n\nBlobParallelUploadOptions options = new BlobParallelUploadOptions(inputStream, length)\n    .setRequestConditions(new BlobRequestConditions().setIfNoneMatch(\"*\"));\n\nblobClient.uploadWithResponse(options, null, Context.NONE);\n```\n\n### Download Data\n\n```java\n\u002F\u002F Download to BinaryData\nBinaryData content = blobClient.downloadContent();\nString text = content.toString();\n\n\u002F\u002F Download to file\nblobClient.downloadToFile(\"downloaded-file.txt\");\n```\n\n### Download to Stream\n\n```java\ntry (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {\n    blobClient.downloadStream(outputStream);\n    byte[] data = outputStream.toByteArray();\n}\n```\n\n### Download with InputStream\n\n```java\nimport com.azure.storage.blob.specialized.BlobInputStream;\n\ntry (BlobInputStream blobIS = blobClient.openInputStream()) {\n    byte[] buffer = new byte[1024];\n    int bytesRead;\n    while ((bytesRead = blobIS.read(buffer)) != -1) {\n        \u002F\u002F Process buffer\n    }\n}\n```\n\n### Upload via OutputStream\n\n```java\nimport com.azure.storage.blob.specialized.BlobOutputStream;\n\ntry (BlobOutputStream blobOS = blobClient.getBlockBlobClient().getBlobOutputStream()) {\n    blobOS.write(\"Data to upload\".getBytes());\n}\n```\n\n### List Blobs\n\n```java\nimport com.azure.storage.blob.models.BlobItem;\n\n\u002F\u002F List all blobs\nfor (BlobItem blobItem : containerClient.listBlobs()) {\n    System.out.println(\"Blob: \" + blobItem.getName());\n}\n\n\u002F\u002F List with prefix (virtual directory)\nimport com.azure.storage.blob.models.ListBlobsOptions;\n\nListBlobsOptions options = new ListBlobsOptions().setPrefix(\"folder\u002F\");\nfor (BlobItem blobItem : containerClient.listBlobs(options, null)) {\n    System.out.println(\"Blob: \" + blobItem.getName());\n}\n```\n\n### List Blobs by Hierarchy\n\n```java\nimport com.azure.storage.blob.models.BlobListDetails;\n\nString delimiter = \"\u002F\";\nListBlobsOptions options = new ListBlobsOptions()\n    .setPrefix(\"data\u002F\")\n    .setDetails(new BlobListDetails().setRetrieveMetadata(true));\n\nfor (BlobItem item : containerClient.listBlobsByHierarchy(delimiter, options, null)) {\n    if (item.isPrefix()) {\n        System.out.println(\"Directory: \" + item.getName());\n    } else {\n        System.out.println(\"Blob: \" + item.getName());\n    }\n}\n```\n\n### Delete Blob\n\n```java\nblobClient.delete();\n\n\u002F\u002F Delete if exists\nblobClient.deleteIfExists();\n\n\u002F\u002F Delete with snapshots\nimport com.azure.storage.blob.models.DeleteSnapshotsOptionType;\nblobClient.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null, null, Context.NONE);\n```\n\n### Copy Blob\n\n```java\nimport com.azure.storage.blob.models.BlobCopyInfo;\nimport com.azure.core.util.polling.SyncPoller;\n\n\u002F\u002F Async copy (for large blobs or cross-account)\nSyncPoller\u003CBlobCopyInfo, Void> poller = blobClient.beginCopy(\"\u003Csource-blob-url>\", Duration.ofSeconds(1));\npoller.waitForCompletion();\n\n\u002F\u002F Sync copy from URL (for same account)\nblobClient.copyFromUrl(\"\u003Csource-blob-url>\");\n```\n\n### Generate SAS Token\n\n```java\nimport com.azure.storage.blob.sas.*;\nimport java.time.OffsetDateTime;\n\n\u002F\u002F Blob-level SAS\nBlobSasPermission permissions = new BlobSasPermission().setReadPermission(true);\nOffsetDateTime expiry = OffsetDateTime.now().plusDays(1);\n\nBlobServiceSasSignatureValues sasValues = new BlobServiceSasSignatureValues(expiry, permissions);\nString sasToken = blobClient.generateSas(sasValues);\n\n\u002F\u002F Container-level SAS\nBlobContainerSasPermission containerPermissions = new BlobContainerSasPermission()\n    .setReadPermission(true)\n    .setListPermission(true);\n    \nBlobServiceSasSignatureValues containerSasValues = new BlobServiceSasSignatureValues(expiry, containerPermissions);\nString containerSas = containerClient.generateSas(containerSasValues);\n```\n\n### Blob Properties and Metadata\n\n```java\nimport com.azure.storage.blob.models.BlobProperties;\n\n\u002F\u002F Get properties\nBlobProperties properties = blobClient.getProperties();\nSystem.out.println(\"Size: \" + properties.getBlobSize());\nSystem.out.println(\"Content-Type: \" + properties.getContentType());\nSystem.out.println(\"Last Modified: \" + properties.getLastModified());\n\n\u002F\u002F Set metadata\nMap\u003CString, String> metadata = Map.of(\"key1\", \"value1\", \"key2\", \"value2\");\nblobClient.setMetadata(metadata);\n\n\u002F\u002F Set HTTP headers\nBlobHttpHeaders headers = new BlobHttpHeaders()\n    .setContentType(\"application\u002Fjson\")\n    .setCacheControl(\"max-age=86400\");\nblobClient.setHttpHeaders(headers);\n```\n\n### Lease Blob\n\n```java\nimport com.azure.storage.blob.specialized.BlobLeaseClient;\nimport com.azure.storage.blob.specialized.BlobLeaseClientBuilder;\n\nBlobLeaseClient leaseClient = new BlobLeaseClientBuilder()\n    .blobClient(blobClient)\n    .buildClient();\n\n\u002F\u002F Acquire lease (-1 for infinite)\nString leaseId = leaseClient.acquireLease(60);\n\n\u002F\u002F Renew lease\nleaseClient.renewLease();\n\n\u002F\u002F Release lease\nleaseClient.releaseLease();\n```\n\n## Error Handling\n\n```java\nimport com.azure.storage.blob.models.BlobStorageException;\n\ntry {\n    blobClient.download(outputStream);\n} catch (BlobStorageException e) {\n    System.out.println(\"Status: \" + e.getStatusCode());\n    System.out.println(\"Error code: \" + e.getErrorCode());\n    \u002F\u002F 404 = Blob not found\n    \u002F\u002F 409 = Conflict (lease, etc.)\n}\n```\n\n## Proxy Configuration\n\n```java\nimport com.azure.core.http.ProxyOptions;\nimport com.azure.core.http.netty.NettyAsyncHttpClientBuilder;\nimport java.net.InetSocketAddress;\n\nProxyOptions proxyOptions = new ProxyOptions(\n    ProxyOptions.Type.HTTP,\n    new InetSocketAddress(\"localhost\", 8888));\n\nBlobServiceClient client = new BlobServiceClientBuilder()\n    .endpoint(\"\u003Cendpoint>\")\n    .sasToken(\"\u003Csas-token>\")\n    .httpClient(new NettyAsyncHttpClientBuilder().proxy(proxyOptions).build())\n    .buildClient();\n```\n\n## Environment Variables\n\n```bash\nAZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;AccountName=...\nAZURE_STORAGE_ACCOUNT_URL=https:\u002F\u002F\u003Caccount>.blob.core.windows.net\n```\n\n## Trigger Phrases\n\n- \"Azure Blob Storage Java\"\n- \"upload download blob\"\n- \"blob container SDK\"\n- \"storage streaming\"\n- \"SAS token generation\"\n- \"blob metadata properties\"\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,244,305,"2026-05-16 13:07:46",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":43},"1c4b6abc-c437-420d-8116-e2b6894a77ac","1.0.0","azure-storage-blob-java.zip",3103,"uploads\u002Fskills\u002F1f91f5f6-de5b-4521-b074-06ce5e37404d\u002Fazure-storage-blob-java.zip","0eca2e6b9b5df0a6739814bb85fefc0a7992207c2d38c5ff51c22902aa92ba58","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":10315}]","2026-05-16 13:07:47",{"code":45,"message":46,"data":47},200,"success",{"items":48,"stats":49,"page":52},[],{"averageRating":50,"totalRatings":50,"ratingCounts":51},0,[50,50,50,50,50],{"limit":53,"offset":50,"hasMore":54,"nextOffset":53,"ratedOnly":16},15,false]