Skip to content

Commit

Permalink
增加 selectObjectContent
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Sep 20, 2020
1 parent 9d94011 commit 4d93221
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,71 @@ function restoreObject() {
});
}

function selectObjectContent() {
// 查询 CSV
cos.selectObjectContent({
Bucket: config.Bucket, // Bucket 格式:test-1250000000
Region: config.Region,
Key: '1.csv',
SelectType: 2,
SelectRequest: {
Expression: "Select * from COSObject",
ExpressionType: "SQL",
InputSerialization: {
CSV: {
FileHeaderInfo: "IGNORE",
RecordDelimiter: "\\n",
FieldDelimiter: ",",
QuoteCharacter: "\"",
QuoteEscapeCharacter: "\"",
Comments: "#",
AllowQuotedRecordDelimiter: "FALSE"
}
},
OutputSerialization: {
CSV: {
QuoteFields: "ASNEEDED",
RecordDelimiter: "\\n",
FieldDelimiter: ",",
QuoteCharacter: "\"",
QuoteEscapeCharacter: "\""
}
},
RequestProgress: {
Enabled: "FALSE"
}
},
}, function (err, data) {
logger.log(err || data);
});
// 查询 JSON
cos.selectObjectContent({
Bucket: config.Bucket, // Bucket 格式:test-1250000000
Region: config.Region,
Key: '1.json',
SelectType: 2,
SelectRequest: {
Expression: "Select b from COSObject",
ExpressionType: "SQL",
InputSerialization: {
JSON: {
Type: "DOCUMENT",
},
},
OutputSerialization: {
JSON: {
RecordDelimiter: "\n"
},
},
RequestProgress: {
Enabled: "FALSE"
}
},
}, function (err, data) {
logger.log(err || data);
});
}

function abortUploadTask() {
cos.abortUploadTask({
Bucket: config.Bucket, /* 必须 */ // Bucket 格式:test-1250000000
Expand Down Expand Up @@ -1140,6 +1205,7 @@ function deleteFolder() {
'deleteObject',
'deleteMultipleObject',
'restoreObject',
'selectObjectContent',
'abortUploadTask',
'sliceUploadFile',
'cancelTask',
Expand Down

0 comments on commit 4d93221

Please sign in to comment.