aliyun / alibabacloud-oss-sdk

The OSS SDK. Powered by Darabonba.
Apache License 2.0
20 stars 8 forks source link

What is Darabonba? What is this SDK? #257

Closed frenchvandal closed 3 years ago

frenchvandal commented 3 years ago

你好, Darabonba是什么? I am developing a TypeScript GitHub action to upload some generated files to my OSS bucket. I used the ali-sdk/ali-oss package, can I use this one instead? Is this stable? What are the differences between ali-sdk/ali-oss and aliyun/alibabacloud-oss-sdk? 对不起,我会说一点儿中文。 谢谢你! Philippe 李北洛

github-actions[bot] commented 3 years ago

感谢您为阿里云 OSS SDK 提交宝贵的建议

AxiosLeo commented 3 years ago

Darabonba is a domain-specific language for OpenAPI applications. It can be used for any style of API to generate SDKs, code samples, test cases, etc...

You can start with darabonba-cli to understand and use Darabonba.

AxiosLeo commented 3 years ago

There are some darabonba packages in alibabacloud-sdk

frenchvandal commented 3 years ago

What is a TeaObject type?

import {Config} from '@alicloud/oss-client';
import {getInput} from '@actions/core';

export const credentials: Config = {
  bucket: getInput('bucket'),
  region: getInput('region'),
  accessKeyId: getInput('accessKeyId'),
  accessKeySecret: getInput('accessKeySecret'),
};

I got the following error in VSCode:

const credentials: Config Property 'toMap' is missing in type '{ bucket: string; region: string; accessKeyId: string; accessKeySecret: string; }' but required in type 'Config'.ts(2741) tea.d.ts(40, 5): 'toMap' is declared here.

What kind of input are you expecting?

export declare class Model {
    [key: string]: any;
    constructor(map?: TeaObject);
    toMap(): TeaObject;
}

My goal is to be able to declare a new OSS instance:

const client: OSS = new OSS(credentials);

peze commented 3 years ago

you can use to make the credentials has function toMap

export const credentials: Config = new Config({
  bucket: getInput('bucket'),
  region: getInput('region'),
  accessKeyId: getInput('accessKeyId'),
  accessKeySecret: getInput('accessKeySecret'),
});
frenchvandal commented 3 years ago

@peze thank you a lot!

Is there a documentation somewhere? The logic seems different from ali-sdk/ali-oss.

I iterate in a string array to upload files into my OSS bucket. With ali-sdk/ali-oss, my code was:

import OSS, {PutObjectResult} from 'ali-oss';

const client: OSS = new OSS(credentials);

    for await (const file of localFiles) {
      const objectName: string = file.replace(homeDir, '');
      const response: PutObjectResult = await client.put(objectName, file);

If I switch to import ... from '@alicloud/oss-client';, my logic is broken.