Sign inSign up

ehwest/sfx_creation_service

By ehwest

•Updated almost 8 years ago

This is a service that creates and returns an MS-DOS executable (.exe).

Image
0

1.0K

ehwest/sfx_creation_service repository overview

73a35568ead5 twiconnect/sfx-creator-service:1.0 "npm start" 2 months ago Up 2 months 0.0.0.0:3000->3000/tcp

docker run twiconnect/sfx-creator-service:1.0 "npm start" -p 3000:3000

curl -XPOST -H "Content-Type: application/json" -H "x-api-key: f84e2396-9c14-11e8-98d0-529269fb1459" -d { "files": [ { "path": "f1.txt", "content": "ZmlsZS0xLWNvbnRlbnQ=" },{ "path": "f2.txt", "content": "ZmlsZS0yLWNvbnRlbnQ=" } ] } localhost:3000/zip

Based on SFX code this container provides a service derived from https://github.com/vk-twiconnect/sfx-creator-service/blob/master/setup.sh⁠

PHP Client code

//List the files to be included. These must be in the current directory. //The files may have anything in them, including binary data. // $list_of_files[] = "cab1.cab"; $list_of_files[] = "TWIConnect.Client.Setup.msi"; $list_of_files[] = "TWIConnect.Client.Setup.wixpdb"; $list_of_files[] = "INSTALL_INSTRUCTIONS.txt"; $list_of_files[] = "Configuration.json"; // // // //prefix $inp = "{"; $inp .= '"files": [';

//build json for each file foreach($list_of_files as $key=>$one_file){ if($key==count($list_of_files)-1){ $sep = ""; }else{ $sep = ", "; } $inp .= ' {'; $inp .= ' "path": "' . $one_file . '",'; $inp .= ' "content": "' . base64_encode(file_get_contents($one_file)) . '"'; $inp .= ' }' . $sep ; }//foreach //json wrapper $inp .= ']'; $inp .= "}";

//something was sqirrley with this where we don't get back the same //file that was written for some reason... this fixed that by making all the files different

$localfilename = "localFile_" . $nowtime; $f1 = fopen($localfilename,"w"); fwrite($f1,$inp); fclose($f1);

$cmd = 'curl -XPOST -H "Content-Type: application/json" -H "x-api-key: f84e2396-9c14-11e8-98d0-529269fb1459" -d ' . "'" . '@./' . $localfilename . "'" . ' 68.199.43.204:3000/zip 2> /dev/null ';

$out2=exec($cmd, $out1);

//print ($out2); //out2 is pure json $purejson = json_decode($out2); $archiveContent = $purejson->archiveContent; //print($archiveContent);

Tag summary

Content type

Image

Digest

Size

28.1 MB

Last updated

almost 8 years ago

docker pull ehwest/sfx_creation_service