Shared Smalltalk Workspace 5DVGNZHZTBL0

http://ws.stfx.eu/5DVGNZHZTBL0

Doit | Raw | Getting Started Workspace | Home | New
|user authToken zipImage entity answerJSON ephemericUrl|
"Ephemeric cloud managed runtime: https://www.pharocloud.com/kb/tutorial/ephemeric_cloud_managed_runtime"
"How to connect an ephmeric instance to a remote database through a secure channel"

"Ephemeric cloud credentials (available at http://www.pharocloud.com)"
user := ''.
authToken := ''.


ZnConstants maximumEntitySize: 50*1024*1024.


"Create a zip archive from the image file"
ZipArchive new 
	addFile: Smalltalk imageFile basename;
	addFile: 'stunnel.conf';
	addFile: 'psk.txt';	
	writeToFileNamed: Smalltalk imageFile basename,'.zip'.
	
	
zipImage := (Smalltalk imageFile basename,'.zip') asFileReference.

"Create HTTP multi-part post-query"
entity := ZnMultiPartFormDataEntity new 
	addPart: (ZnMimePart 
		fieldName: 'imageZip'
		fileName: Smalltalk imageFile basename
		entity: (ZnStreamingEntity 
			readBinaryFrom: zipImage binaryReadStream 
			usingType: 'application/zip' asMIMEType 
			andLength: zipImage size)); yourself.

"Send the query, read output"
answerJSON := (ZnClient new
		beOneShot;
		url: ('https://www.pharocloud.com/api/ephemerics/user/{1}?auth={2}' format: { user. authToken }) asUrl;
		entity: entity;
		timeout: 60*1000;
		post;
		response) contents.

"Get and show the URL of your appliance"
ephemericUrl := ('http://', (answerJSON subStrings: '"') first) asUrl.
ephemericUrl inspect.
THIS SOFTWARE SERVICE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OR SERVICE PROVIDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE SERVICE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE SERVICE.