|
69 | 69 |
|
70 | 70 | {% for parameter in method.parameters.body %} |
71 | 71 |
|
72 | | -{% if parameter.type == 'file' %} |
| 72 | +{% if parameter.type == 'file' and method.packaging %} |
| 73 | + $cloudFunctionPath = realpath(__DIR__.'/../../../files/'.${{ parameter.name | caseCamel }}); |
| 74 | + $cloudFunctionParentDir = dirname($cloudFunctionPath, 1); |
| 75 | + $cloudFunctionDirName = basename(${{ parameter.name | caseCamel }}); |
| 76 | + if (file_exists($cloudFunctionPath) === false ) { |
| 77 | + throw new Exception("Path doesn't exist. Please ensure that the path is within the current directory. "); |
| 78 | + } |
| 79 | + $archiveName = 'code.tar.gz'; |
| 80 | + $volumeMountPoint = realpath(__DIR__.'/../../../files/'); |
| 81 | + exec("tar -zcvf $archiveName -C ${cloudFunctionParentDir} $cloudFunctionDirName && mv ${archiveName} ${volumeMountPoint}"); |
| 82 | + $archivePath = realpath($volumeMountPoint."/$archiveName");$archivePath = realpath($volumeMountPoint."/$archiveName"); |
| 83 | + $cFile = new \CURLFile($archivePath, 'application/x-gzip' , basename($archivePath)); |
| 84 | + |
| 85 | + $params['{{ parameter.name }}'] = $cFile; |
| 86 | +
|
| 87 | +{% elseif parameter.type == 'file' %} |
| 88 | +
|
73 | 89 | ${{ parameter.name | caseCamel }} = realpath(__DIR__.'/../../../files/'.${{ parameter.name | caseCamel }}); |
74 | 90 | if (file_exists(${{ parameter.name | caseCamel }}) === false ) { |
75 | 91 | throw new Exception("Path doesn't exist. Please ensure that the path is within the current directory. "); |
76 | 92 | } |
77 | | -{% if method.packaging %} |
78 | | - $archive_file_name = '{{ parameter.name | caseCamel }}.tar'; |
79 | | - $archive_file_path = dirname(${{ parameter.name | caseCamel }}, 1)."/${archive_file_name}"; |
80 | | - $archive = new PharData($archive_file_path); |
81 | | - $archive->buildFromDirectory(${{ parameter.name | caseCamel }}); |
82 | | - $archive->compress(Phar::GZ); |
83 | | - ${{ parameter.name | caseCamel }} = $archive_file_path.'.gz'; |
84 | | -{% endif %} |
| 93 | +
|
85 | 94 | $cFile = new \CURLFile(${{ parameter.name | caseCamel }}, {% if method.packaging %} 'application/x-gzip' {% else %} 'image/png' {% endif %}, basename(${{ parameter.name | caseCamel }})); |
86 | 95 | $params['{{ parameter.name }}'] = $cFile; |
| 96 | + |
87 | 97 | {% else %} |
88 | 98 | $params['{{ parameter.name }}'] = ${{ parameter.name | caseCamel }}; |
89 | 99 | {% endif %} |
|
117 | 127 | {% endif %} |
118 | 128 |
|
119 | 129 | {% if method.packaging %} |
120 | | - unlink($archive_file_path); // as we already obtained a tar.gz |
121 | | - unlink($archive_file_path.'.gz'); |
| 130 | + unlink($archivePath); |
122 | 131 | {% endif %} |
123 | 132 | }); |
124 | 133 |
|
|
0 commit comments