提供的头文件相关参数及方法
//任务回调函数
//任务开始时和每上传下载完成一片后调用
//already_size:已经完成的字节数
//total_size:总字节数
//user_data:设置的用户数据
//返回值:OSS_ERR_OK-任务继续,其他-用户提前终止任务
typedef int (CALLBACK *cbTransNotify)(long long already_size, long long total_size, void* user_data);
//从磁盘上传文件
//cloud_id:保存文件的云存储id
//file_name[IN]:要上传的本地文件名称,绝对路径
//key_buffer[OUT]:成功上传到云存储后返回给用户的对象名,下载时需要用到,不会大于260字节
//key_buffer_size:key_buffer缓存字节数
//bucket_buffer[OUT]:成功上传到云存储的bucket名字,不会大于260字节
//bucket_buffer_size:bucket_buffer缓存字节数
//cb:回调函数,每上传完成一片调用,如果回调返回值是OSS_ERR_OK继续上传下一片,
// 否则终止任务
//user_data[IN]:用户设置的回调参数
//返回值:成功返回OSS_ERR_OK,失败返回其他值
OSS_SDK int OSS_UploadFromFile(int cloud_id, const char* file_name, char* key_buffer, int key_buffer_size,
char* bucket_buffer, int bucket_buffer_size, cbTransNotify cb, void* user_data);
以上这是 C++部分代码,下面是我用C#写的调用代码,一直掉不通,请各位大神给予指点,那里出问题
// 定义委托
[UnmanagedFunctionPointerAttribute(CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public delegate int cbTransNotify(long already_size, long total_size, IntPtr user_data);
// 上传文件
[DllImport("oss_api.dll", CharSet = CharSet.Ansi)]
public static extern int OSS_UploadFromFile(int cloud_id, string file_name, StringBuilder key_buffer, int key_buffer_size, StringBuilder bucket_buffer, int bucket_buffer_size, cbTransNotify notify, IntPtr user_data);
/// <summary>
/// 函数指针
/// </summary>
/// <param name="already_size"></param>
/// <param name="total_size"></param>
/// <param name="user_data"></param>
/// <returns></returns>
public static int Oss_HD_CbTransNotify(long already_size, long total_size, IntPtr user_data)
{
return 0;
}
/// <summary>
/// 上传文件
/// </summary>
/// <param name="cloud_id"></param>
/// <param name="file_name"></param>
/// <param name="key_buffer"></param>
/// <param name="key_buffer_size"></param>
/// <param name="bucket_buffer"></param>
/// <param name="bucket_buffer_size"></param>
/// <param name="notify"></param>
/// <param name="user_data"></param>
/// <returns></returns>
public static int Oss_HD_UploadFromFile(int cloud_id, string file_name, StringBuilder key_buffer, int key_buffer_size, StringBuilder bucket_buffer, int bucket_buffer_size)
{
cbTransNotify cb = new cbTransNotify(Oss_HD_CbTransNotify);
return OSS_UploadFromFile(cloud_id, file_name, key_buffer, key_buffer_size, bucket_buffer, bucket_buffer_size, cb, (IntPtr)0);
}
int cloud_id = 101;
string file_name = @"D:\HD\0138@FILE0002-20150529095645.MP4";
int key_buffer_size = 260;
StringBuilder key_buffer = new StringBuilder(260);
int bucket_buffer_size = 260;
StringBuilder bucket_buffer = new StringBuilder(260);
int b = UploadHDPlatFormInterface.Oss_HD_UploadFromFile(cloud_id, file_name, key_buffer, key_buffer_size, bucket_buffer, bucket_buffer_size);
// 日志记录
WriteDebugInfo("OSS_UploadFromFile函数指针返回值 " + b);
一直找不出问题出在哪里,接口一直掉不同,请各位大神给予指点
什么云?不行你就自己调用webapi