Spring Cloud Google Cloud Storage 出站通道適配器

2024-01-10 15:59 更新

出站通道適配器允許將文件寫(xiě)入Google Cloud Storage。當(dāng)它收到包含類(lèi)型為File的有效負(fù)載的Message時(shí),它將將該文件寫(xiě)入適配器中指定的Google Cloud Storage存儲(chǔ)桶。

這是有關(guān)如何配置Google Cloud Storage出站通道適配器的示例。

@Bean
@ServiceActivator(inputChannel = "writeFiles")
public MessageHandler outboundChannelAdapter(Storage gcs) {
  GcsMessageHandler outboundChannelAdapter = new GcsMessageHandler(new GcsSessionFactory(gcs));
  outboundChannelAdapter.setRemoteDirectoryExpression(new ValueExpression<>("your-gcs-bucket"));

  return outboundChannelAdapter;
}
以上內(nèi)容是否對(duì)您有幫助:
在線(xiàn)筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)