-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from fengyhack/master
新增LabMD5,修复UnixTimestamp计算的问题
- Loading branch information
Showing
51 changed files
with
16,744 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Binary file added
BIN
+1.23 KB
examples/Examples.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
Oops, something went wrong.