2017-10-08 50 views
1

從Postman我正在發佈到我的邏輯應用程序。我發送以下內容:如何解析表單數據觸發器中的文件名

{ 
    "headers": { 
     "Cache-Control": "no-cache", 
     "Connection": "keep-alive", 
     "Accept": "*/*", 
     "Accept-Encoding": "gzip,deflate", 
     "Host": "prod-24.centralus.logic.azure.com:443", 
     "User-Agent": "PostmanRuntime/6.4.0", 
     "Postman-Token": "19018057-41ef-4f96-a3a1-cdbf0a1918bc", 
     "Content-Length": "486", 
     "Content-Type": "multipart/form-data; boundary=--------------------------117388521639837767242570" 
    }, 
    "body": { 
     "$content-type": "multipart/form-data; boundary=--------------------------117388521639837767242570", 
     "$content": "LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTExNzM4ODUyMTYzOTgzNzc2NzI0MjU3MA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJzb2Z0d2FyZSI7IGZpbGVuYW1lPSJmaWxlLnppcCINCkNvbnRlbnQtVHlwZTogYXBwbGljYXRpb24vemlwDQoNClBLAwQUAAAACACZVEhLillatwgAAAAGAAAACAAAAGZpbGUudHh0K0ktLslNBQBQSwECHwAUAAAACACZVEhLillatwgAAAAGAAAACAAkAAAAAAAAACAAAAAAAAAAZmlsZS50eHQKACAAAAAAAAEAGADAJqtCS0DTATYTq0JLQNMBlyUeQktA0wFQSwUGAAAAAAEAAQBaAAAALgAAAAAADQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tMTE3Mzg4NTIxNjM5ODM3NzY3MjQyNTcwDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImRldmljZUlkIg0KDQpzMTIzNDUNCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0xMTczODg1MjE2Mzk4Mzc3NjcyNDI1NzAtLQ0K", 
     "$multipart": [ 
      { 
       "headers": { 
        "Content-Disposition": "form-data; name=\"software\"; filename=\"file.zip\"", 
        "Content-Type": "application/zip" 
       }, 
       "body": { 
        "$content-type": "application/zip", 
        "$content": "UEsDBBQAAAAIAJlUSEuKWVq3CAAAAAYAAAAIAAAAZmlsZS50eHQrSS0uyU0FAFBLAQIfABQAAAAIAJlUSEuKWVq3CAAAAAYAAAAIACQAAAAAAAAAIAAAAAAAAABmaWxlLnR4dAoAIAAAAAAAAQAYAMAmq0JLQNMBNhOrQktA0wGXJR5CS0DTAVBLBQYAAAAAAQABAFoAAAAuAAAAAAA=" 
       } 
      }, 
      { 
       "headers": { 
        "Content-Disposition": "form-data; name=\"deviceId\"" 
       }, 
       "body": { 
        "$content-type": "application/octet-stream", 
        "$content": "czEyMzQ1" 
       } 
      } 
     ] 
    } 
} 

我想獲取文件名的值和文件的內容。 我將要創建的Blob文件

感謝,

回答

1

以下是我正在做。我假設你正在使用HTTP觸發器設置爲POST。在HTTP觸發器添加一個Foreach連接器之後,如果您正在執行多文件上傳,則可以遍歷所有文件。

在foreach來源將是這個表達式: triggerOutputs().body['$multipart']

內的foreach你可以用這個醜陋的表達,這是非常糟糕的解析文件名,但它的工作原理: replace(replace(item().headers['Content-Disposition'], 'form-data; name="myFileUploadInput"; filename="', ''), '"', '')

AFAIK有沒有正則表達式的支持在表達式中,這會更好。你可能可以用substring做一些事情,但它也可能非常難看。

下面是你如何獲得在foreach中的身體保存到blob存儲:item().body

相關問題