ADD: MacCloud/S3: step-145: Upyun USS

This commit is contained in:
rich2014 2025-05-21 21:04:20 +08:00
commit 07f3afffbd
4 changed files with 94 additions and 3 deletions

View file

@ -187,6 +187,11 @@
<IsPartOfProject Value="True"/>
<UnitName Value="uQiniuKODOClient"/>
</Unit>
<Unit>
<Filename Value="drivers/aws/upyunuss/uupyunussclient.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="uUpyunUSSClient"/>
</Unit>
</Units>
</ProjectOptions>
<CompilerOptions>
@ -196,7 +201,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="../../../../sdk;util;drivers/root;drivers;drivers/aws;drivers/aws/aliyunoss;drivers/oauth2/box;drivers/oauth2/dropbox;drivers/oauth2/onedrive;drivers/oauth2/yandex;wfx/ui;wfx;drivers/oauth2;drivers/aws/tencentcos;drivers/aws/amazons3;drivers/aws/s3compatible;drivers/aws/huaweiobs;drivers/qiniukodo;drivers/aws/qiniukodo"/>
<OtherUnitFiles Value="../../../../sdk;util;drivers/root;drivers;drivers/aws;drivers/aws/aliyunoss;drivers/oauth2/box;drivers/oauth2/dropbox;drivers/oauth2/onedrive;drivers/oauth2/yandex;wfx/ui;wfx;drivers/oauth2;drivers/aws/tencentcos;drivers/aws/amazons3;drivers/aws/s3compatible;drivers/aws/huaweiobs;drivers/qiniukodo;drivers/aws/qiniukodo;drivers/aws/upyunuss"/>
<UnitOutputDirectory Value="../lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>

View file

@ -14,7 +14,7 @@ type
{ TQiniuKODOGetAllBucketsSession }
TQiniuKODOGetAllBucketsSession = class( TS3GetAllBucketsWithRegionFunctionSession )
TQiniuKODOGetAllBucketsSession = class( TS3GetAllBucketsSession )
protected
procedure constructBucket( const bucket: TS3Bucket; const xmlBucket: NSXMLElement ); override;
function getConnectionDataOfService: TAWSConnectionData; override;

View file

@ -0,0 +1,81 @@
unit uUpyunUSSClient;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils,
CocoaAll,
uCloudDriver, uAWSCore, uS3Client,
uMiniUtil;
type
{ TUpyunUSSGetAllBucketsSession }
TUpyunUSSGetAllBucketsSession = class( TS3GetAllBucketsSession )
protected
procedure constructBucket( const bucket: TS3Bucket; const xmlBucket: NSXMLElement ); override;
function getConnectionDataOfService: TAWSConnectionData; override;
function getEndPointOfRegion(const region: String): String; override;
end;
{ TUpyunUSSClient }
TUpyunUSSClient = class( TS3Client )
public
class function driverName: String; override;
class function createInstance: TCloudDriver; override;
protected
function autoBuildBuckets: TS3Buckets; override;
end;
implementation
{ TUpyunUSSGetAllBucketsSession }
procedure TUpyunUSSGetAllBucketsSession.constructBucket( const bucket: TS3Bucket; const xmlBucket: NSXMLElement );
begin
bucket.connectionData.region:= 'global';
bucket.connectionData.endPoint:= self.getEndPointOfRegion( bucket.connectionData.region );
end;
function TUpyunUSSGetAllBucketsSession.getConnectionDataOfService: TAWSConnectionData;
begin
Result.region:= '';
Result.endPoint:= 's3.api.upyun.com';
Result.bucketName:= '';
end;
function TUpyunUSSGetAllBucketsSession.getEndPointOfRegion( const region: String ): String;
begin
Result:= 's3.api.upyun.com'
end;
{ TUpyunUSSClient }
class function TUpyunUSSClient.driverName: String;
begin
Result:= 'UpyunUSS';
end;
class function TUpyunUSSClient.createInstance: TCloudDriver;
begin
Result:= TUpyunUSSClient.Create;
end;
function TUpyunUSSClient.autoBuildBuckets: TS3Buckets;
var
session: TS3GetAllBucketsSession = nil;
begin
try
session:= TUpyunUSSGetAllBucketsSession.Create( _authSession );
Result:= session.listBuckets;
finally
FreeAndNil( session );
end;
end;
end.

View file

@ -12,7 +12,7 @@ uses
uOAuth2Core, uOAuth2Client, uDropBoxClient, uYandexClient, uOneDriveClient, uBoxClient,
uAWSCore, uS3Client,
uAmazonS3Client, uS3CompatibleClient,
uAliyunOSSClient, uTencentCOSClient, uHuaweiOBSClient, uQiniuKODOClient,
uAliyunOSSClient, uTencentCOSClient, uHuaweiOBSClient, uQiniuKODOClient, uUpyunUSSClient,
uMiniUtil;
type
@ -67,6 +67,7 @@ resourcestring
rsTencentCOSDisplayName = 'Tencent Cloud COS';
rsHuaweiOBSDisplayName = 'Huawei Cloud OBS';
rsQiniuKODODisplayName = 'Qiniu Cloud KODO';
rsUpyunUSSDisplayName = 'Upyun USS';
type
@ -384,6 +385,10 @@ begin
WFXCloudDriverConfigManager.register( TQiniuKODOClient.driverName, TWFXS3Config );
cloudDriverManager.register( TQiniuKODOClient );
WFXCloudDriverMenuItems.add( TQiniuKODOClient.driverName, rsQiniuKODODisplayName );
WFXCloudDriverConfigManager.register( TUpyunUSSClient.driverName, TWFXS3Config );
cloudDriverManager.register( TUpyunUSSClient );
WFXCloudDriverMenuItems.add( TUpyunUSSClient.driverName, rsUpyunUSSDisplayName );
end;
procedure TWFXCloudDriverConfigManager.register(const name: String;