Home NewsX California Consumer Privacy Act (CCPA) Opt-Out Icon

California Consumer Privacy Act (CCPA) Opt-Out Icon

by info.odysseyx@gmail.com
0 comment 1 views


background

For sending multi-part/form data content in Logic App, there is official documentation that introduces how to achieve this. Create a workflow that calls an external endpoint or other workflow – Azure Logic Apps | Microsoft rear….

But recently, if we Content processing If the file name section contains non-ASCII characters (Chinese, Japanese characters), the file name is displayed as ????. If you implement Http operations according to the documentation.

machine

through testing curl There is an alternative way to send multipart/form-data by encoding all payloads as base64 encoded strings using the command: Here’s a sample payload sent from CURL:

{
  "$content-type": "multipart/form-data; boundary=------------------------boundary",
  "$content": "base64 encoded content"
}

The decoded base64 string is in the usual multipart/form-data format.

--------------------------boundary
Content-Disposition: form-data; name="filename"; filename="[File name]"
Content-Type: application/octet-stream

File content binary
--------------------------boundary--

avatar

Depending on the mechanism, you will see that it is also possible to send multi-part forms using Logic App Http actions using the same format.o The only obstacle is how to combine the border header, file binary and border footer into a single base64 string.

In most situations we get the file contents as separate base64 strings. As we all know, you can’t concatenate multiple base64 strings directly, so decoding may be wrong.

So, we first need to convert all three parts to binary and combine them into a single byte.[]Then convert it all together to a base64 string. There is no built-in expression/function to handle this.

As a workaround, you can prepare three base64 encoded strings (boundary header, file content and border footer) and then use the new feature “C# inline” to achieve this approach. Here is sample code:

// Add the required libraries
#r "Newtonsoft.Json"
#r "Microsoft.Azure.Workflows.Scripting"
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Workflows.Scripting;
using Newtonsoft.Json.Linq;

public static async Task Run(WorkflowContext context, ILogger log)
{
  var fileContent = (await context.GetActionResults("FileContent").ConfigureAwait(false)).Outputs;

  string header = (await context.GetActionResults("BoundaryHeader").ConfigureAwait(false)).Outputs;

  string footer = (await context.GetActionResults("BoundaryFooter").ConfigureAwait(false)).Outputs;

  byte[] headerBinary = Convert.FromBase64String(header.ToString());
  byte[] footerBinary = Convert.FromBase64String(footer.ToString());
  byte[] fileContentBinary = Convert.FromBase64String(fileContent.ToString());

  List allBytes = new List();
  allBytes.AddRange(headerBinary);
  allBytes.AddRange(fileContentBinary);
  allBytes.AddRange(footerBinary);

  string base64Content = Convert.ToBase64String(allBytes.ToArray());

  return new Results
  {
    Message = base64Content
  };
}

public class Results
{
  public string Message {get; set;}
}

After you get the output from your C# action, you can configure it all into an Http action.





Source link

You may also like

Leave a Comment

Our Company

Welcome to OdysseyX, your one-stop destination for the latest news and opportunities across various domains.

Newsletter

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

Laest News

@2024 – All Right Reserved. Designed and Developed by OdysseyX