* FileTest.cs: chore: 增加图片缩略图接口
* AVFile.cs:
parent
13b0789d2b
commit
65b54eb5d3
|
@ -27,5 +27,13 @@ namespace LeanCloudTests {
|
||||||
Assert.NotNull(file.ObjectId);
|
Assert.NotNull(file.ObjectId);
|
||||||
TestContext.Out.WriteLine($"file: {file.ObjectId}, {file.Url}");
|
TestContext.Out.WriteLine($"file: {file.ObjectId}, {file.Url}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task Thumbnail() {
|
||||||
|
AVFile file = await AVFile.GetFileWithObjectIdAsync("5d64ac55d5de2b006c1fe3d8");
|
||||||
|
Assert.NotNull(file);
|
||||||
|
TestContext.Out.WriteLine($"url: {file.Url}");
|
||||||
|
TestContext.Out.WriteLine($"thumbnail url: {file.GetThumbnailUrl(28, 28)}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,6 +243,12 @@ namespace LeanCloud {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetThumbnailUrl(int width, int height,
|
||||||
|
int quality = 100, bool scaleToFit = true, string format = "png") {
|
||||||
|
int mode = scaleToFit ? 2 : 1;
|
||||||
|
return $"{Url}?imageView/{mode}/w/{width}/h/{height}/q/{quality}/format/{format}";
|
||||||
|
}
|
||||||
|
|
||||||
internal static AVFileController FileController {
|
internal static AVFileController FileController {
|
||||||
get {
|
get {
|
||||||
return AVPlugins.Instance.FileController;
|
return AVPlugins.Instance.FileController;
|
||||||
|
@ -587,7 +593,7 @@ namespace LeanCloud {
|
||||||
/// <remarks>获取之后并没有实际执行下载,只是加载了文件的元信息以及物理地址(Url)
|
/// <remarks>获取之后并没有实际执行下载,只是加载了文件的元信息以及物理地址(Url)
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static Task<AVFile> GetFileWithObjectIdAsync(string objectId, CancellationToken cancellationToken) {
|
public static Task<AVFile> GetFileWithObjectIdAsync(string objectId, CancellationToken cancellationToken) {
|
||||||
string currentSessionToken = AVUser.CurrentUser.SessionToken;
|
string currentSessionToken = AVUser.CurrentUser?.SessionToken;
|
||||||
return FileController.GetAsync(objectId, currentSessionToken, cancellationToken).OnSuccess(_ => {
|
return FileController.GetAsync(objectId, currentSessionToken, cancellationToken).OnSuccess(_ => {
|
||||||
var filestate = _.Result;
|
var filestate = _.Result;
|
||||||
return new AVFile(filestate);
|
return new AVFile(filestate);
|
||||||
|
|
Loading…
Reference in New Issue