Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
V1.01 - New Feature: Upload folder tree
Browse files Browse the repository at this point in the history
The API test form can now upload all files and folders from a starting
point
  • Loading branch information
stanyork committed Oct 15, 2015
1 parent 787ddd6 commit e0f4513
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 229 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,4 @@ pip-log.txt

#Mr Developer
.mr.developer.cfg
Cloud Element Test Form/Resources/Hard Drive Move Up.gif
3 changes: 3 additions & 0 deletions Cloud Element Test Form/Cloud Element Test Form.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
<ItemGroup>
<None Include="Resources\Folder Refresh.gif" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\External Hard Drive Move Up.gif" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
416 changes: 221 additions & 195 deletions Cloud Element Test Form/Form1.Designer.cs

Large diffs are not rendered by default.

67 changes: 57 additions & 10 deletions Cloud Element Test Form/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,26 +414,70 @@ private Boolean HasGottenFolder()
return result;
}

private async void toolStripButton1_Click(object sender, EventArgs e)
private async void toolStripButton1_Click(object sender, EventArgs e) // upload one file
{
if (!HasGottenFolder()) return;
if (openFileDialog1.ShowDialog() == DialogResult.Cancel) return;
var MIMEType = Cloud_Elements_API.Tools.FileTypeToMimeContentType(System.IO.Path.GetExtension(openFileDialog1.FileName));
string TargetPath = this.CurrentFolderPath;
string SourceFileName = System.IO.Path.GetFileName(openFileDialog1.FileName);
if (!TargetPath.EndsWith("/")) TargetPath += "/";
TargetPath += SourceFileName;
var sizeInBytes = new System.IO.FileInfo(openFileDialog1.FileName).Length;

List<String> TagList = new List<String>();
TagList.Add("sfCE.NET");

Cloud_Elements_API.CloudFile Result = await APIConnector.PostFile(openFileDialog1.OpenFile(), MIMEType,
TargetPath, "Uploaded by .NET Connector Test Tool!",
TagList.ToArray(), false, sizeInBytes);
await uploadFile( openFileDialog1.FileName, this.CurrentFolderPath, TagList ,"Uploaded by .NET Connector Test Tool!");
}

async private Task uploadFile(string sourceFileName, string targetPath, List<String> tagList, string description)
{
var MIMEType = Cloud_Elements_API.Tools.FileTypeToMimeContentType(System.IO.Path.GetExtension(sourceFileName));
StatusMsg("Uploading " + sourceFileName);

string SourceFileName = System.IO.Path.GetFileName(sourceFileName);
if (!targetPath.EndsWith("/")) targetPath += "/";
targetPath += SourceFileName;
System.IO.FileInfo fInfo = new System.IO.FileInfo(sourceFileName);

var sizeInBytes = fInfo.Length;


Cloud_Elements_API.CloudFile Result = await APIConnector.PostFile(fInfo.OpenRead(), MIMEType,
targetPath, description,
tagList.ToArray(), false, sizeInBytes);

fInfo = null;

}

async private Task uploadFolder(string sourcePath, string targetPath)
{
List<String> TagList = new List<String>();
foreach (var fn in System.IO.Directory.GetFiles(sourcePath))
{
await uploadFile( fn, targetPath, TagList, "");
}

string nestedPath;
foreach (var folderName in System.IO.Directory.GetDirectories(sourcePath))
{
nestedPath = string.Format("{0}/{1}",targetPath ,new System.IO.DirectoryInfo(folderName).Name);
await uploadFolder( folderName, nestedPath );
}



}



private async void uploadSubtreeToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!HasGottenFolder()) return;

if (folderBrowserUploadTree.ShowDialog() == DialogResult.Cancel) return;

await uploadFolder(folderBrowserUploadTree.SelectedPath, this.CurrentFolderPath);

}


private async void tsBtnNewFolder_Click(object sender, EventArgs e)
{
if (!HasGottenFolder()) return;
Expand Down Expand Up @@ -612,6 +656,7 @@ private async void toolStripButton1_Click_1(object sender, EventArgs e)
await RefreshCurrentFolder();
}


private async void tsGetFileLink_Click(object sender, EventArgs e)
{
if (!HasGottenFolder()) return;
Expand Down Expand Up @@ -815,6 +860,8 @@ private async void tsRemoveEmptyFolders_Click(object sender, EventArgs e)
TestStatusMsg(string.Format("Folders Removed: {0}", CountOfFoldersRemoved));
}






Expand Down
26 changes: 3 additions & 23 deletions Cloud Element Test Form/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -174,29 +174,6 @@
teSFIkzwmCXHpEQptu9gsnzsa539WKyxY5bajoB9dhG46BiAw+FARkaGp0w56MwH7owi7Eo6hIb9iIDF
kRg9U4WRM9WSaP6ODYrCFxHRqKqqkprvcLrQ0NkjNue4llxC7h1eEZ5EQqA4UoyJoiBPxpgStL2b0Gq1
MBqNMs9f+pPH83fGz+8fd8L2rG1fTXEAAAAASUVORK5CYII=
</value>
</data>
<data name="tsBtnUpload.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAPOSURBVEhLtZQNTNRlHMf/h4dirxIWgmBxuMBwFoUVL5mO
smVWc5BmRMQmGMla0dBh1iRxaDB5GdJgNzgY0uAG54ARThwyYZxDh+xkJwMGA8cx2HmDHQx2j/fpAbLl
bK7m9d1++79/Ps/v92x/5b/k9RMBvJMXyJ+Xrk+0VsOPrfEk6sJdL0npDCDFqOFgZyDVt35iT95m10ly
+qPJG44md3gbpwcjyRl6i0ujZUQc9neNpMWWSbP1GI3Wwxim0qibTJXnR+kYMhCc9IxrJN12Hd32cq7O
lHHVrmXKMUCvvY40XZxrBK22bNpsObTb8rgyXYBdTBFf/Lbr9qF0LAbt2D5043FUWhKYFrd57dv1rhMc
Mb3E0b7NHDNv4bg5lLG5G4SkeLlOEHNew94mDftbNMS3ajBZ29h00NN1gqhCDfdqe/FGGvpLCEv3/n8E
MbowstuS+bjoEX8bu7P8+PCUPx/katiR+wLbC+SxKICdv/qyrzKIzCa5F9WbGK0IYKDUh1tn12LOX/PP
0oHGQ4y0HsFiPM2d3gKmrmVT2/w+KW0aDnUFLFenhtT2IDI6ty5VeaEfV457Yczy4o5+A44L/sw1rsOq
92X20hZEz7soc/2pWI1JjMuWRy9+hencJzSlr6cyTv1X6dPXUqULprjlZQquv0luYwjaXB+6TnozWhXI
hD4Qa3MoCz17cQ6kyfoOYU6Sgp0ozuFU7g6mIPqT5c1EaV93H7zp++cY/i2MwapXGa6J4HZ9FJbz4Uw0
RDJtjMM5cgrneBnO0Tyc/ZIjVy2MWxGdIYjLASjL8CTu9iXgvBnHZPXT9wkWa/FFcdEb0fwUC/UesDAF
dhNOixbn4DeI6zsQ3W8guuRY2gMRrb6I3z0RDY+hiP4Dy3DTZ4gbsQyVuD8ouPAsoulJFupWYa9SsxjR
E424Fimhr0joi4g2f0SLF6LxCRyGVThqVjBXqZKCvi8Qvftx9sTID3bTlal6UNDwOPO1K7FXqJk86wYO
K6IjWEI3LMtlZ8LggaNWzfw5FfZyBVuJwmS+Iveg91PZ4h7Z4i65mm0stIcypX8ec6EnlzM8qE9yZ75m
JdPlaiYK3Rg+qULMdEvoGilejUMvn1e7MVuhYqZUwVqkYP5ZQZcg4feS+JEfVZlBjNQvbsxGOW+fJYDD
sJrZands2hWM57sxdEKFKV0KLJVL0MUR2LXL0JFfFCq+/Bv0YYmNcifvgDsdWWosxRJ+RsWAHF1vmoIx
WUEM/oCteHkETakKieH/EvywfB2hULBLwRCr4Lj5ORnvuQD66FGUPwDrQO2ogIy6OgAAAABJRU5ErkJg
gg==
</value>
</data>
<data name="tsBtnNewFolder.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down Expand Up @@ -269,6 +246,9 @@
<value>909, 17</value>
</metadata>
<metadata name="saveSecretsFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>207, 56</value>
</metadata>
<metadata name="folderBrowserUploadTree.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 56</value>
</metadata>
</root>
12 changes: 11 additions & 1 deletion Cloud Element Test Form/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cloud Element Test Form/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,7 @@
<data name="Folder Refresh" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Folder Refresh.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="External Hard Drive Move Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\External Hard Drive Move Up.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e0f4513

Please sign in to comment.