Giter VIP home page Giter VIP logo

amazon-storage-service's Introduction

amazon-storage-service

A wrapper class that uses native delphi integration to amazon storage service.

Delphi Supported Versions Platforms

Prerequisites

[Optional] For ease I recommend using the Boss for installation

  • Boss - Dependency Manager for Delphi

Installation using Boss (dependency manager for Delphi applications)

boss install github.com/mateusvicente100/amazon-storage-service

Manual Installation

Add the following folder to your project, in Project > Options > Resource Compiler > Directories and Conditionals > Include file search path

../amazon-storage-service/src

Getting Started

You need to use Amazon.Storage.Service

uses Amazon.Storage.Service;

First of all you need at once configure the amazon settings to connect in the server. This sould be done on start of your program.

procedure InitializeAmazonService;
begin
  TAmazonStorageServiceConfig.GetInstance.AccessKey := 'your-access-key';
  TAmazonStorageServiceConfig.GetInstance.SecretKey := 'your-secret-key';
  TAmazonStorageServiceConfig.GetInstance.Region := TAmazonRegion.YourRegion;  
  TAmazonStorageServiceConfig.GetInstance.Protocol := TAmazonProtocol.http;
  TAmazonStorageServiceConfig.GetInstance.MainBucketName := 'your-main-bucket-name'; // Optional  
end;

List buckets

You can list all your buckets

procedure ListAllBuckets;
var
  LBuckets: TStrings;
  I: Integer;
begin
  LBuckets := TAmazonStorageService.New.ListBuckets;
  try     
    for I := 0 to Pred(LBuckets.Count) do
      memoLog.Lines.Add(LBuckets.Names[I]);
  finally
    LBuckets.Free;
  end;
end;  

Create a bucket

You can create a bucket sending the bucket name

procedure CreateBucket(const ABucketName: string);
begin
  TAmazonStorageService.New.CreateBucket(ABucketName);
end;  

Delete a bucket

You can delete a bucket sending the bucket name

procedure CreateBucket(const ABucketName: string);
begin
  TAmazonStorageService.New.DeleteBucket(ABucketName);
end;  

List files from a bucket

You can list all files from one specific bucket

procedure ListAllFilesFromBucket(const ABucketName: string);
var
  LFiles: TAmazonBucketResult;
  LFile: TAmazonObjectResult;
begin
  LFiles := TAmazonStorageService.New.GetBucket(ABucketName);
  try    
    for LFile in LFiles.Objects do    
      memoLog.Lines.Add(LFile.Name);      
  finally
    LFiles.Free;
  end;
end;

Upload a file

You can upload a file using the file directory and main bucket name or using a specific bucket name

procedure UploadFile(const AFileDirectory: string);
begin
  TAmazonStorageService.New.UploadFile(AFileDirectory);
end;  

Delete a file

You can delete a file using the file name and main bucket name or using a specific bucket name

procedure DeleteFile(const AFileName: string);
begin
  TAmazonStorageService.New.DeleteFile(AFileName);
end;  

Download a file

You can download a file using the file name with the bucket main name or using a specific bucket name

procedure DownloadFile(const AFileName: string);
begin
  TAmazonStorageService.New.DownloadFile(AFileName);
end;  

amazon-storage-service's People

Contributors

mateusvicente100 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.