本演示项目在Unity for Android Build中启用部分华为HMS和AGC服务,对应的类和函数的名称和用法相同。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

61 行
1.5 KiB

using HuaweiService;
using HuaweiService.CloudStorage;
using UnityEngine;
namespace CloudStorageTest
{
public class StreamDownloadTest
{
private AGCStorageManagement mAGCStorageManagement;
private string storageFileName= "MetadataLoader.cpp";
private void initAGCStorageManagement()
{
mAGCStorageManagement = AGCStorageManagement.getInstance();
}
public void run()
{
streamDownloadTest();
Debug.Log("StorageExceptionTest finished.");
}
private void streamDownloadTest()
{
initAGCStorageManagement();
StorageReference reference = mAGCStorageManagement.getStorageReference(storageFileName);
StreamDownloadTask streamTask = reference.getStream();
if (streamTask == null)
{
Debug.Log("downloadStream is null");
}
MyStreamHandler myStreamHandler = new MyStreamHandler();
StreamDownloadTask streamTaskWithHandler = reference.getStream(myStreamHandler);
if (streamTaskWithHandler == null)
{
Debug.Log("streamTaskWithHandler is null");
}
Debug.Log("streamDownloadTest success");
}
}
public class MyStreamHandler : StreamDownloadTask.StreamHandler{
public override void readStream(StreamDownloadTask.StreamDownloadResult var1, InputStream var2)
{
InputStream ins = var1.getStream();
if (ins == null)
{
Debug.Log("streamDownloadTest getStream fail, ins is null");
}
long count = var1.getTotalByteCount();
long transferred = var1.getBytesTransferred();
Debug.Log("MyStreamHandler, totalCount: " + count + "transferred: " + transferred);
}
}
}