Shared Smalltalk Workspace BTURJDRFU7BO

http://ws.stfx.eu/BTURJDRFU7BO

Doit | Raw | Getting Started Workspace | Home | New
|user authToken zipImage entity answerJSON ephemericUrl|


"Snapshot current state to a new file"
"IMPORTANT: execute the next line separately from the rest of the script"
"Smalltalk saveAsNewVersion."


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

"Create a zip archive from the image file"
ZipArchive new addFile: Smalltalk imageFile basename; 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.