【发布时间】:2015-04-28 09:01:42
【问题描述】:
我正在使用 Spray-can 托管一个 REST 服务,用户可以将文件上传到该服务。下面给出了监听传入请求的代码块:
def receive: Receive = {
case _: Http.Connected => sender ! Http.Register(self)
case req@HttpRequest(HttpMethods.POST, Uri.Path("/upload"), headers, entity, _) =>
logger.info("Received file upload request.")
// Process the uploaded data using the 'entity' object
我使用这个 curl 命令上传文件:
curl --data-binary @inputFile.csv 'devserver:8998/upload?tenant=DressShop&facility=CityCenter&customer=Jimmy'
我面临的挑战是我无法从请求中获取文件名“inputFile.csv”,尽管我从“实体”对象获取数据。我尝试仔细研究 API,但找不到任何获取文件名的方法。
我的目标是确保我只允许上传 csv 文件。
【问题讨论】:
标签: spray spray-client