Camel 无法将csv文件上载到Azure存储blob

amrnrhlw  于 2022-11-07  发布在  Apache
关注(0)|答案(1)|浏览(227)

以下代码未将示例MY_TEST_FILE.csv上载到Azure存储blob。无法找出问题或找到执行此操作的任何示例。代码中缺少任何内容吗?日志文件中没有错误,在Azure存储中未找到该文件
'''

StorageSharedKeyCredential credential = new StorageSharedKeyCredential("test", "test");
        String uri = "https://test.blob.core.windows.net";

        BlobServiceClient client = new BlobServiceClientBuilder()
                .endpoint(uri)
                .credential(credential)
                .buildClient();
        CamelContext mycontext = new DefaultCamelContext();
        mycontext.getRegistry().bind("client", client);

        mycontext.setStreamCaching(true);
        mycontext.addRoutes(new RouteBuilder() {
            @Override
            public void configure() {

                from("file:c://folder2?fileName=MY_TEST_FILE.csv&noop=true").to("azure-storage-blob://test/report?blobName=MY_TEST_FILE.csv&operation=uploadBlockBlob&serviceClient=#client");

            }
        });
        mycontext.start();'''
daupos2t

daupos2t1#

您可能需要为azure-storage-blob组件提供凭据。

StorageSharedKeyCredential credentials = new StorageSharedKeyCredential(accountName, accountKey);
mycontext.getRegistry().bind("credentials", credentials);

from("file:c://folder2?fileName=MY_TEST_FILE.csv&noop=true")
    .to("azure-storage-blob:accountName/containerName?"
         + "blobName=MY_TEST_FILE.csv&operation=uploadBlockBlob"
         + "&credentials=#credentials");

请注意,#beanId已过时,您可能必须根据camel版本切换到#bean:beanId

相关问题