Can't create .zip file with Azure Logic Apps' SharePoint Create File action - azure

I'm trying to create a .zip file by passing the returned body of an HTTP GET request to SharePoint's Create File.
Body is:
{
"$content-type": "application/zip",
"$content": "UEsDBBQACA...="
}
Shouldn't this just work? The docs only define the Create File field as "Content of the file." but that's not super informative...
I believe I've done this before with a file that was application/pdf and it worked. Unfortunately, I can't find that Logic App (I think it may have been an experiment I've since deleted).
I should note that the Create File action does create a valid .zip file, in that it's not corrupt, but archive is empty. It's supposed to contain a single .csv file.
I tried decoding the Base64 content and it's definitely binary data.
Any idea where I'm going wrong?

I test with Postman and when I use the form-data way to POST the request, I found the .zip file couldn't be open. Then I check the Logic App run history and I find the problem is if just use the triggerbody() as the file content it will fail.
This is because the triggerbody() not just have the $content, so I change the expression to triggerBody()['$multipart'][0]['body'] then it works and the .zip file is full.

Related

How to read xlsx content downloaded using content-disposition node

Is there any method to read the downloaded file content(not the file name) using node js? I'm getting my downloaded file content-disposition: attachment;filename=hello11.xlsx like this. I want provide the URI to my excel data extraction function. but couldn't figure out how to get the URI because my get Request returns nothing but a file downloaded to the browser.
I found a similar question but it's using java

Passing Dropbox file contents to an Azure Function from a Logic App

I am trying a sample app with the workflow
Wait for new file (csv) in dropbox folder
Load the file contents
Pass the file contents to an azure function to further process
I am getting stuck on how to pass the file contents to the azure function. I keep getting an unsupportedmediatype error with "Message": "The WebHook request must contain an entity body formatted as JSON
How do I get the output of the second stage into a function?
What I typically do in those scenario's is create a json-body for the Function and add the messagecontent I want to sent to the function as a Base64-string as a part of the json-body (eg. Payload, or Body).
Similar approach on how Logic Apps handles certain media types at runtime.
{"OriginalFileName" : "myfile.csv", "PayLoad" : "ContentBase64String"}

multiple files in nodejs

I'm a nodejs noob & I use express. I use normal file structure as a db for my content.
I found my self in need to send download responses to some folders. so i used easy-zip (npm-package) & it works great. but the zipped file must be saved to the disk.
I need a way to compress the folder on the fly then return response with out saving it to the disk ?
Also i want to add a feature to enable me to compress multiple folders & send them as a response & i couldn't do that with easy-zip because the folders are in different directories.
I tried to send response to download multiple files but if found out that it can't be done because every response can only have one file.
How can i send a response with multiple folders (compressed on the fly) as one .zip file ?
Just read the source of easy-zip, https://github.com/owenchong/easy-zip/blob/master/easy-zip.js#L111
you should probably do
var zip6 = new EasyZip();
zip6.zipFolder('../easy-zip',function(){
zip6.writeToResponse(response,'attachment.zip');
}, {rootFolder: 'easy-zip6'});

File operation on S3 file without download

I want to know the File type using "file" command without downloading file from S3 in Nodejs.
so aim is to only hit the file , fire "File" command on it and retrieve it's output. How can I achieve this without downloading?
Why not use the NodeJS S3 SDK to get the file details. There is a method that returns the object metadata. You can check the object ContentType to know its file type. It is returned in the response json when you make a request for an object's metadata.
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#headObject-property

Spring MVC - Change in .Exe file to .txt makes browser change content type

In my Spring MVC 3.0 based application I am trying to test the file upload functionality with some validations.
In one validation I changed .exe(executable) file to .txt , and expecting that exe file shouldn't be uploaded in the system.But it gets uploaded.
I am checking content type of file but in this case once file extension is changed it's content types also gets changed from "application/octet-stream" to "text/plain".
I am testing on Firefox and Google Chrome. And At Controller level Uploaded file is being read using MultipartFile.
Is there any way by which I get the original content type of file in this case "application/octet-stream" ?
When we change the extension of the file before uploading it ..It depends on Operating System weather the MIME type will change or not. Moreover, it is the responsibility of the browser to find out the Mime Type and set into the request header which is being read in the controller.

Resources