Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/CURLS Amazon S3 upload
Required plugins for this example: MBS CURL Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/CURLS Amazon S3 upload
This example is the version from Tue, 18th Feb 2019.
Project "CURLS Amazon S3 upload.rbp"
Filetype text
End FileTypes
Class MainWindow Inherits Window
Control UploadButton Inherits PushButton
ControlInstance UploadButton Inherits PushButton
EventHandler Sub Action() DoUpload End EventHandler
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control ResultText Inherits Label
ControlInstance ResultText Inherits Label
End Control
Private Sub DoUpload() dim e as integer dim d as new UploadCURL dim p as Picture = LogoMBS // this is the image data to upload 'd.InputData = p.GetData(picture.FormatJPEG, picture.QualityHigh) dim file as FolderItem = SpecialFolder.Desktop.Child("test.jpg") call d.OpenMTInputFile(file) dim AWSAccessKeyId as String = "xxx" dim AWSSecretAccessKey as String = "yyy" dim Region as String = "eu-central-1" dim BucketName as string = "zzz" dim FileName as string = "test.jpg" dim Service as String = "s3" dim Path as String = "/" + BucketName + "/" + Filename dim Domain as String // empty for auto dim Verb as String = "PUT" dim HashedPayload as String // empty for auto HashedPayload = SHA256MBS.HashFile(file) 'FileName = "The-Big-Bang-Theory.jpg" Region = "eu-central-1" // "us-east-1" domain = "monkeybreadsoftwaretest.s3.eu-central-1.amazonaws.com" // "s3.amazonaws.com" BucketName = "monkeybreadsoftwaretest" AWSAccessKeyId = "AKIAJ2KZENQFJ34ZLKJA" AWSSecretAccessKey = "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" Path = "/" + Filename // "/" + Filename call d.SetupAWS(AWSAccessKeyId, AWSSecretAccessKey, Region, Service, Path, Domain, Verb, HashedPayload) e=d.Perform listbox1.addrow "Result: "+str(e) dim DebugMessage as string = d.DebugData // check in debugger on error dim OutputData as string = d.OutputData dim HTTPResult as integer = d.GetInfoResponseCode if e <> 0 or HTTPResult <> 200 then break end if End Sub
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu5 = ""
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu4 = ""
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = ""
End MenuBar
Class App Inherits Application
End Class
Class UploadCURL Inherits CURLSMBS
EventHandler Function Progress(dltotal as Int64, dlnow as Int64, ultotal as Int64, ulnow as Int64, percent as double) As boolean if ultotal=0 then MainWindow.listbox1.addrow "Uploading..." else MainWindow.listbox1.addrow "Uploading "+Format(ulnow/ultotal,"-0%")+" "+stR(ulnow)+" of "+str(ultotal) end if End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS CURL Plugin.

MBS FileMaker blog