Skip to content

Commit

Permalink
Merge pull request #154 from fengyhack/master
Browse files Browse the repository at this point in the history
新增LabMD5,修复UnixTimestamp计算的问题
  • Loading branch information
fengyhack committed Feb 24, 2017
2 parents ab023ac + bd05589 commit 56292f4
Show file tree
Hide file tree
Showing 51 changed files with 16,744 additions and 108 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
**2017-02-24**

最新版本v7.2.12,适用于.NET Framework 2.0+ , .NET Core 和 UWP

新增:MD5哈希函数的3rdParty实现(避免FIPS问题)

修复:日期时间戳转换的bug(时间基准设置不对)

* * *

**2017-02-16**

最新版本v7.2.11,适用于.NET Framework 2.0+ , .NET Core 和 UWP
Expand Down
12 changes: 4 additions & 8 deletions README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@ This C# SDK is built based on Qiniu Cloud API (see below), and it can be used on

You can have a better view of this SDK by checking the documnets given below:

* [SDK-reference HTML Online](http://oiy037d6a.bkt.clouddn.com/csharp-sdk-ref-v7.2.11/index.html)
* [SDK-reference HTML Online](http://oiy037d6a.bkt.clouddn.com/csharp-sdk-ref-v7.2.12/index.html)

* [SDK-reference CHM Offline](http://oiy037d6a.bkt.clouddn.com/QiniuCSharpSDK-Ref-v7.2.11.chm)
* [SDK-reference CHM Offline](http://oiy037d6a.bkt.clouddn.com/QiniuCSharpSDK-Ref-v7.2.12.chm)

Want to know more about how to using this SDK? Are you trying to find some code examples based on this SDK? These documents or links below will be helpful:
Want to know more about how to using this SDK? Are you trying to find some code examples based on this SDK? These examples (**UWP app** example included) or links below will be helpful:

* [github/csharp-sdk-shared-examples](https://github.com/fengyhack/csharp-sdk-shared-examples)
* [github/csharp-sdk-shared-examples](https://github.com/qiniu/csharp-sdk/tree/master/examples)

* [SDK manual | examples](http://oiy037d6a.bkt.clouddn.com/csharp-sdk-man-v7.2.11/index.html)

Or if you want to develop **UWP apps**, see example(s) given below.

* [github | csharp-sdk-example-uwp](https://github.com/fengyhack/csharp-sdk-example-uwp)

##How-to-install

Releases can be found [here](https://github.com/fengyhack/csharp-sdk-shared/releases), choose the one you need and unzipped it, then add reference to the *.dll file in your project.
Expand Down
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@

以下文档用于检索SDK接口、属性说明,它将有助于您理解SDK的结构。

* [HTML在线浏览](http://oiy037d6a.bkt.clouddn.com/csharp-sdk-ref-v7.2.11/index.html)
* [HTML在线浏览](http://oiy037d6a.bkt.clouddn.com/csharp-sdk-ref-v7.2.12/index.html)

* [CHM文件下载](http://oiy037d6a.bkt.clouddn.com/QiniuCSharpSDK-Ref-v7.2.11.chm)
* [CHM文件下载](http://oiy037d6a.bkt.clouddn.com/QiniuCSharpSDK-Ref-v7.2.12.chm)

以下文档/链接提供一些基本示例,参考这些示例可以帮助您更快熟悉如何使用这套SDK。
以下链接提供了一些示例(包含**UWP应用**示例),参考这些示例可以帮助您更快熟悉如何使用这套SDK。

* [github | csharp-sdk-examples](https://github.com/fengyhack/csharp-sdk-examples)
* [github | csharp-sdk-examples](https://github.com/qiniu/csharp-sdk/tree/master/examples)

* [C# SDK使用指南 | 代码示例](http://oiy037d6a.bkt.clouddn.com/csharp-sdk-man-v7.2.11/index.html)

如果您想开发**UWP应用**,您也可以参考如下示例。

* [github | csharp-sdk-example-uwp](https://github.com/fengyhack/csharp-sdk-example-uwp)
* [C# SDK使用指南 | 代码示例](http://oiy037d6a.bkt.clouddn.com/csharp-sdk-man-v7.2.12/index.html)

##如何安装

Expand Down
Binary file removed bin/qiniu-csharp-sdk-v7.2.11.zip
Binary file not shown.
Binary file added bin/qiniu-csharp-sdk-v7.2.12.zip
Binary file not shown.
17 changes: 7 additions & 10 deletions doc/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ <h1 id="qiniu-cloud-c-sdk">Qiniu (Cloud) C# SDK</h1>
</div>
</div>



<h2 id="关于">关于</h2>

<p>此 C# SDK 适用于.NET Framework 2.0+ , .NET Core 以及UWP(Windows 10 通用应用),基于七牛云API参考手册构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。</p>
Expand All @@ -46,19 +48,14 @@ <h2 id="sdk文档">SDK文档</h2>

<p>以下文档用于检索SDK接口、属性说明,它将有助于您理解SDK的结构。</p>

<ul><li><p><a href="http://oiy037d6a.bkt.clouddn.com/csharp-sdk-ref-v7.2.11/index.html" target="_blank">HTML在线浏览</a></p></li>
<li><p><a href="http://oiy037d6a.bkt.clouddn.com/QiniuCSharpSDK-Ref-v7.2.11.chm" target="_blank">CHM文件下载</a></p></li>
</ul>

<p>以下文档/链接提供一些基本示例,参考这些示例可以帮助您更快熟悉如何使用这套SDK。</p>

<ul><li><p><a href="https://github.com/fengyhack/csharp-sdk-examples" target="_blank">github | csharp-sdk-examples</a></p></li>
<li><p><a href="http://oiy037d6a.bkt.clouddn.com/csharp-sdk-man-v7.2.11/index.html" target="_blank">C# SDK使用指南 | 代码示例</a></p></li>
<ul><li><p><a href="http://oiy037d6a.bkt.clouddn.com/csharp-sdk-ref-v7.2.12/index.html" target="_blank">HTML在线浏览</a></p></li>
<li><p><a href="http://oiy037d6a.bkt.clouddn.com/QiniuCSharpSDK-Ref-v7.2.12.chm" target="_blank">CHM文件下载</a></p></li>
</ul>

<p>如果您想开发<strong>UWP应用</strong>,您也可以参考如下示例</p>
<p>以下链接提供一些示例(包含<strong>UWP</strong>示例),参考这些示例可以帮助您更快熟悉如何使用这套SDK</p>

<ul><li><a href="https://github.com/fengyhack/csharp-sdk-example-uwp" target="_blank">github | csharp-sdk-example-uwp</a></li>
<ul><li><p><a href="https://github.com/qiniu/csharp-sdk/tree/master/examples" target="_blank">github | csharp-sdk-examples</a></p></li>
<li><p><a href="http://oiy037d6a.bkt.clouddn.com/csharp-sdk-man-v7.2.12/index.html" target="_blank">C# SDK使用指南 | 代码示例</a></p></li>
</ul>

<h2 id="如何安装">如何安装</h2>
Expand Down
Binary file modified doc/README.pdf
Binary file not shown.
Empty file added examples/CHANGELOG.md
Empty file.
40 changes: 40 additions & 0 deletions examples/Examples.UWP.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Qiniu.Examples.UWP", "Examples.UWP\Qiniu-Example-UWP.csproj", "{50714AB2-D3BA-4B80-92F3-E02D980CF346}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Debug|ARM.ActiveCfg = Debug|ARM
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Debug|ARM.Build.0 = Debug|ARM
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Debug|ARM.Deploy.0 = Debug|ARM
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Debug|x64.ActiveCfg = Debug|x64
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Debug|x64.Build.0 = Debug|x64
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Debug|x64.Deploy.0 = Debug|x64
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Debug|x86.ActiveCfg = Debug|x86
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Debug|x86.Build.0 = Debug|x86
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Debug|x86.Deploy.0 = Debug|x86
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Release|ARM.ActiveCfg = Release|ARM
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Release|ARM.Build.0 = Release|ARM
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Release|ARM.Deploy.0 = Release|ARM
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Release|x64.ActiveCfg = Release|x64
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Release|x64.Build.0 = Release|x64
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Release|x64.Deploy.0 = Release|x64
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Release|x86.ActiveCfg = Release|x86
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Release|x86.Build.0 = Release|x86
{50714AB2-D3BA-4B80-92F3-E02D980CF346}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions examples/Examples.UWP/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application
x:Class="QiniuExampleUWP.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:QiniuExampleUWP"
RequestedTheme="Light">

</Application>
106 changes: 106 additions & 0 deletions examples/Examples.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace QiniuExampleUWP
{
/// <summary>
/// 提供特定于应用程序的行为,以补充默认的应用程序类。
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// 初始化单一实例应用程序对象。这是执行的创作代码的第一行,
/// 已执行,逻辑上等同于 main() 或 WinMain()。
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}

/// <summary>
/// 在应用程序由最终用户正常启动时进行调用。
/// 将在启动应用程序以打开特定文件等情况下使用。
/// </summary>
/// <param name="e">有关启动请求和过程的详细信息。</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;

// 不要在窗口已包含内容时重复应用程序初始化,
// 只需确保窗口处于活动状态
if (rootFrame == null)
{
// 创建要充当导航上下文的框架,并导航到第一页
rootFrame = new Frame();

rootFrame.NavigationFailed += OnNavigationFailed;

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: 从之前挂起的应用程序加载状态
}

// 将框架放在当前窗口中
Window.Current.Content = rootFrame;
}

if (e.PrelaunchActivated == false)
{
if (rootFrame.Content == null)
{
// 当导航堆栈尚未还原时,导航到第一页,
// 并通过将所需信息作为导航参数传入来配置
// 参数
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// 确保当前窗口处于活动状态
Window.Current.Activate();
}
}

/// <summary>
/// 导航到特定页失败时调用
/// </summary>
///<param name="sender">导航失败的框架</param>
///<param name="e">有关导航失败的详细信息</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}

/// <summary>
/// 在将要挂起应用程序执行时调用。 在不知道应用程序
/// 无需知道应用程序会被终止还是会恢复,
/// 并让内存内容保持不变。
/// </summary>
/// <param name="sender">挂起的请求的源。</param>
/// <param name="e">有关挂起请求的详细信息。</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: 保存应用程序状态并停止任何后台活动
deferral.Complete();
}
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/Examples.UWP/Assets/StoreLogo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions examples/Examples.UWP/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Page
x:Class="QiniuExampleUWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:QiniuExampleUWP"
Width="800" Height="600">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="5*"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBox Width="400" Height="70" Header="LocalFile" Name="TextBox_LocalFile" Margin="10 0"></TextBox>
<Button Width="100" Height="40" Name="Button_OpenFile" Margin="10,35,10,10" Click="Button_OpenFile_Click">OpenFile</Button>
<Button Width="100" Height="40" Name="Button_UploadFile" Margin="10,30,10,10" Click="Button_UploadFile_Click">UploadFile</Button>
<Button Width="100" Height="40" Name="Button_UploadData" Margin="10,30,10,10" Click="Button_UploadData_Click">UploadData</Button>
</StackPanel>
<ProgressBar Grid.Row="1" Width="750" Height="10" Margin="0 10" Name="ProgressBar_UploadProgress" Minimum="0" Maximum="1.0"></ProgressBar>
<TextBox Grid.Row="2" Name="TextBox_Info" Width="760" TextWrapping="Wrap"></TextBox>
</Grid>
</Page>
107 changes: 107 additions & 0 deletions examples/Examples.UWP/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Storage;
using Windows.Storage.Pickers;
using System.Threading.Tasks;
using Qiniu.Util;
using Qiniu.IO;
using Qiniu.IO.Model;
using Qiniu.CDN;
using Qiniu.CDN.Model;

//“空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 上有介绍

namespace QiniuExampleUWP
{
/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class MainPage : Page
{
private string AK = "<ACCESS_KEY>";
private string SK = "<SECRET_KEY>";

private StorageFile localFile;

public MainPage()
{
this.InitializeComponent();
}

private async void Button_OpenFile_Click(object sender, RoutedEventArgs e)
{
// 设置要支持的文件类型或者任意类型
FileOpenPicker opx = new FileOpenPicker();
opx.FileTypeFilter.Add(".mp4");
opx.FileTypeFilter.Add(".txt");
opx.FileTypeFilter.Add(".png");
localFile = await opx.PickSingleFileAsync();
TextBox_LocalFile.Text = localFile.Path;
}

private async void Button_UploadFile_Click(object sender, RoutedEventArgs e)
{
string saveKey = "uwp-upload-test-1.mp4";

Mac mac = new Mac(AK, SK);
PutPolicy putPolicy = new PutPolicy();
putPolicy.Scope = "test";
putPolicy.SetExpires(30);

string jstr = putPolicy.ToJsonString();
string token = Auth.CreateUploadToken(mac, jstr);

//UploadProgressHandler upph = new UploadProgressHandler(MyUploadProgresHandler);

//UploadManager um = new UploadManager();
//um.SetUploadProgressHandler(upph);
//var result = await um.UploadFileAsync(localFile, saveKey, token);

FormUploader fu = new FormUploader(true);

var result = await fu.UploadFileAsync(localFile, saveKey, token);

TextBox_Info.Text = result.ToString();
}

private void MyUploadProgresHandler(long u,long t)
{
ProgressBar_UploadProgress.Value = 1.0 * u / t;
TextBox_Info.Text = string.Format("上传进度: {0:P}", 1.0 * u / t);
}

private async void Button_UploadData_Click(object sender, RoutedEventArgs e)
{
string saveKey = "uwp-upload-data-test-1";

Mac mac = new Mac(AK, SK);
PutPolicy putPolicy = new PutPolicy();
putPolicy.Scope = "test";
putPolicy.SetExpires(30);

string jstr = putPolicy.ToJsonString();
string token = Auth.CreateUploadToken(mac, jstr);

UploadProgressHandler upph = new UploadProgressHandler(MyUploadProgresHandler);

UploadManager um = new UploadManager();
um.SetUploadProgressHandler(upph);

byte[] data = await FormUploader.ReadToByteArrayAsync(localFile);
var result = await um.UploadDataAsync(data, saveKey, token);
TextBox_Info.Text = result.ToString();
}
}
}

0 comments on commit 56292f4

Please sign in to comment.