Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Initiate Multipart S3 UploadInitiates an Amazon AWS multipart S3 upload. The following is quoted from the Amazon Simple Storage Service Documentation: "The Multipart upload API enables you to upload large objects in parts. You can use this API to upload new large objects or make a copy of an existing object (see Operations on Objects).
Use ChilkatAx-win32.pkg Procedure Test Handle hoRest Boolean iBTls Integer iPort Boolean iBAutoReconnect Boolean iSuccess Variant vAuthAws Handle hoAuthAws String sFileToUploadPath String sResponseXml Handle hoXml String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // Other S3 Multipart Upload Examples: // S3 Upload Parts // Complete Multipart Upload // Abort Multipart Upload // List Parts Get Create (RefClass(cComChilkatRest)) To hoRest If (Not(IsComObjectCreated(hoRest))) Begin Send CreateComObject of hoRest End // Connect to the Amazon AWS REST server. Move True To iBTls Move 443 To iPort Move True To iBAutoReconnect Get ComConnect Of hoRest "s3.amazonaws.com" iPort iBTls iBAutoReconnect To iSuccess // ---------------------------------------------------------------------------- // Important: For buckets created in regions outside us-east-1, // there are three important changes that need to be made. // See Working with S3 Buckets in Non-us-east-1 Regions for the details. // ---------------------------------------------------------------------------- // Provide AWS credentials for the REST call. Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws If (Not(IsComObjectCreated(hoAuthAws))) Begin Send CreateComObject of hoAuthAws End Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY" Set ComSecretKey Of hoAuthAws To "AWS_SECRET_KEY" Set ComServiceName Of hoAuthAws To "s3" Get pvComObject of hoAuthAws to vAuthAws Get ComSetAuthAws Of hoRest vAuthAws To iSuccess // Set the bucket name via the HOST header. // In this case, the bucket name is "chilkat100". Set ComHost Of hoRest To "chilkat100.s3.amazonaws.com" // The local file path (on our local system) to upload. Move "s3_multipart_uploads/somethingBig.zip" To sFileToUploadPath // The HTTP request to initiate a multipart upload is a POST with no body content.. // This is the tricky part: We would be tempted to pass "/somethingBig.zip?uploads" // in the 2nd argument to FullRequestNoBody. However, we must pass only the path without query // params. The "uploads" query param must be added via AddQueryParam. This allows it to be included // in the AWS signature calculation for authentication. Get ComAddQueryParam Of hoRest "uploads" "" To iSuccess Get ComFullRequestNoBody Of hoRest "POST" "/somethingBig.zip" To sResponseXml Get ComLastMethodSuccess Of hoRest To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End // When successful, the S3 Storage service will respond with a 200 response code, // with an XML body. Get ComResponseStatusCode Of hoRest To iTemp1 If (iTemp1 <> 200) Begin // Examine the request/response to see what happened. Get ComResponseStatusCode Of hoRest To iTemp1 Showln "response status code = " iTemp1 Get ComResponseStatusText Of hoRest To sTemp1 Showln "response status text = " sTemp1 Get ComResponseHeader Of hoRest To sTemp1 Showln "response header: " sTemp1 Showln "response body: " sResponseXml Showln "---" Get ComLastRequestStartLine Of hoRest To sTemp1 Showln "LastRequestStartLine: " sTemp1 Get ComLastRequestHeader Of hoRest To sTemp1 Showln "LastRequestHeader: " sTemp1 End // See http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadInitiate.html // for a sample of the XML response. Showln sResponseXml Showln "----" // Save the XML response to a file, and show the UploadId.. Get Create (RefClass(cComChilkatXml)) To hoXml If (Not(IsComObjectCreated(hoXml))) Begin Send CreateComObject of hoXml End Get ComLoadXml Of hoXml sResponseXml To iSuccess Get ComSaveXml Of hoXml "s3_multipart_uploads/initiate.xml" To iSuccess Get ComGetChildContent Of hoXml "UploadId" To sTemp1 Showln "UploadId = " sTemp1 Showln "Multipart upload initiated." End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.