putObjectWithFileData method
Implementation
Future<String?> putObjectWithFileData(String objectKey, List<int> fileData,
{String? token,String? contentType = "image/jpeg"}) async {
cosLog("putObject");
int fileLength = fileData.length;
var req = await getRequest("PUT", objectKey,
headers: {
"content-type": contentType,
"content-length": fileLength.toString()
},
token: token);
req.add(fileData);
var response = await req.close();
cosLog("request-id:" + (response.headers["x-cos-request-id"]?.first ?? ""));
if (response.statusCode != 200) {
String content = await response.transform(utf8.decoder).join("");
cosLog("putObject error content: $content");
return null;
} else {
return objectKey;
}
}