mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Re-enable file sharing.
This commit is contained in:
parent
c6b366f902
commit
2525d422fa
@ -405,35 +405,35 @@ namespace Remotely.ScreenCast.Core.Communication
|
||||
}
|
||||
});
|
||||
|
||||
//Connection.On("SharedFileIDs", (List<string> fileIDs) =>
|
||||
//{
|
||||
// fileIDs.ForEach(id =>
|
||||
// {
|
||||
// var url = $"{conductor.Host}/API/FileSharing/{id}";
|
||||
// var webRequest = WebRequest.CreateHttp(url);
|
||||
// var response = webRequest.GetResponse();
|
||||
// var contentDisp = response.Headers["Content-Disposition"];
|
||||
// var fileName = contentDisp
|
||||
// .Split(";".ToCharArray())
|
||||
// .FirstOrDefault(x => x.Trim().StartsWith("filename"))
|
||||
// .Split("=".ToCharArray())[1];
|
||||
Connection.On("SharedFileIDs", (List<string> fileIDs) =>
|
||||
{
|
||||
fileIDs.ForEach(id =>
|
||||
{
|
||||
var url = $"{conductor.Host}/API/FileSharing/{id}";
|
||||
var webRequest = WebRequest.CreateHttp(url);
|
||||
var response = webRequest.GetResponse();
|
||||
var contentDisp = response.Headers["Content-Disposition"];
|
||||
var fileName = contentDisp
|
||||
.Split(";".ToCharArray())
|
||||
.FirstOrDefault(x => x.Trim().StartsWith("filename"))
|
||||
.Split("=".ToCharArray())[1];
|
||||
|
||||
// var legalChars = fileName.ToCharArray().Where(x => !Path.GetInvalidFileNameChars().Any(y => x == y));
|
||||
var legalChars = fileName.ToCharArray().Where(x => !Path.GetInvalidFileNameChars().Any(y => x == y));
|
||||
|
||||
// fileName = new string(legalChars.ToArray());
|
||||
fileName = new string(legalChars.ToArray());
|
||||
|
||||
// var dirPath = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "RemotelySharedFiles")).FullName;
|
||||
// var filePath = Path.Combine(dirPath, fileName);
|
||||
// using (var fs = new FileStream(filePath, FileMode.Create))
|
||||
// {
|
||||
// using (var rs = response.GetResponseStream())
|
||||
// {
|
||||
// rs.CopyTo(fs);
|
||||
// }
|
||||
// }
|
||||
// Process.Start("explorer.exe", dirPath);
|
||||
// });
|
||||
//});
|
||||
var dirPath = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "RemotelySharedFiles")).FullName;
|
||||
var filePath = Path.Combine(dirPath, fileName);
|
||||
using (var fs = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
using (var rs = response.GetResponseStream())
|
||||
{
|
||||
rs.CopyTo(fs);
|
||||
}
|
||||
}
|
||||
Process.Start("explorer.exe", dirPath);
|
||||
});
|
||||
});
|
||||
|
||||
Connection.On("SessionID", (string sessionID) =>
|
||||
{
|
||||
|
||||
@ -451,34 +451,34 @@ export function UpdateDisplays(selectedDisplay, displayNames) {
|
||||
}
|
||||
}
|
||||
function uploadFiles(fileList) {
|
||||
//ShowMessage("File upload started...");
|
||||
//FileTransferProgress.value = 0;
|
||||
//FileTransferProgress.parentElement.removeAttribute("hidden");
|
||||
//var strPath = "/API/FileSharing/";
|
||||
//var fd = new FormData();
|
||||
//for (var i = 0; i < fileList.length; i++) {
|
||||
// fd.append('fileUpload' + i, fileList[i]);
|
||||
//}
|
||||
//var xhr = new XMLHttpRequest();
|
||||
//xhr.open('POST', strPath, true);
|
||||
//xhr.addEventListener("load", function () {
|
||||
// FileTransferProgress.parentElement.setAttribute("hidden", "hidden");
|
||||
// if (xhr.status === 200) {
|
||||
// ShowMessage("File upload completed.");
|
||||
// MainRc.RCBrowserSockets.SendSharedFileIDs(xhr.responseText);
|
||||
// }
|
||||
// else {
|
||||
// ShowMessage("File upload failed.");
|
||||
// }
|
||||
//});
|
||||
//xhr.addEventListener("error", () => {
|
||||
// FileTransferProgress.parentElement.setAttribute("hidden", "hidden");
|
||||
// ShowMessage("File upload failed.");
|
||||
//});
|
||||
//xhr.addEventListener("progress", function (e) {
|
||||
// FileTransferProgress.value = isFinite(e.loaded / e.total) ? e.loaded / e.total : 0;
|
||||
//});
|
||||
//xhr.send(fd);
|
||||
ShowMessage("File upload started...");
|
||||
FileTransferProgress.value = 0;
|
||||
FileTransferProgress.parentElement.removeAttribute("hidden");
|
||||
var strPath = "/API/FileSharing/";
|
||||
var fd = new FormData();
|
||||
for (var i = 0; i < fileList.length; i++) {
|
||||
fd.append('fileUpload' + i, fileList[i]);
|
||||
}
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', strPath, true);
|
||||
xhr.addEventListener("load", function () {
|
||||
FileTransferProgress.parentElement.setAttribute("hidden", "hidden");
|
||||
if (xhr.status === 200) {
|
||||
ShowMessage("File upload completed.");
|
||||
MainRc.RCBrowserSockets.SendSharedFileIDs(xhr.responseText);
|
||||
}
|
||||
else {
|
||||
ShowMessage("File upload failed.");
|
||||
}
|
||||
});
|
||||
xhr.addEventListener("error", () => {
|
||||
FileTransferProgress.parentElement.setAttribute("hidden", "hidden");
|
||||
ShowMessage("File upload failed.");
|
||||
});
|
||||
xhr.addEventListener("progress", function (e) {
|
||||
FileTransferProgress.value = isFinite(e.loaded / e.total) ? e.loaded / e.total : 0;
|
||||
});
|
||||
xhr.send(fd);
|
||||
}
|
||||
function closeAllHorizontalBars(exceptBarId) {
|
||||
HorizontalBars.forEach(x => {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -499,36 +499,35 @@ export function UpdateDisplays(selectedDisplay: string, displayNames: string[])
|
||||
}
|
||||
|
||||
function uploadFiles(fileList: FileList) {
|
||||
//ShowMessage("File upload started...");
|
||||
//FileTransferProgress.value = 0;
|
||||
//FileTransferProgress.parentElement.removeAttribute("hidden");
|
||||
|
||||
//var strPath = "/API/FileSharing/";
|
||||
//var fd = new FormData();
|
||||
//for (var i = 0; i < fileList.length; i++) {
|
||||
// fd.append('fileUpload' + i, fileList[i]);
|
||||
//}
|
||||
//var xhr = new XMLHttpRequest();
|
||||
//xhr.open('POST', strPath, true);
|
||||
//xhr.addEventListener("load", function () {
|
||||
// FileTransferProgress.parentElement.setAttribute("hidden", "hidden");
|
||||
// if (xhr.status === 200) {
|
||||
// ShowMessage("File upload completed.");
|
||||
// MainRc.RCBrowserSockets.SendSharedFileIDs(xhr.responseText);
|
||||
// }
|
||||
// else {
|
||||
// ShowMessage("File upload failed.");
|
||||
// }
|
||||
//});
|
||||
//xhr.addEventListener("error", () => {
|
||||
// FileTransferProgress.parentElement.setAttribute("hidden", "hidden");
|
||||
// ShowMessage("File upload failed.");
|
||||
//});
|
||||
//xhr.addEventListener("progress", function (e) {
|
||||
// FileTransferProgress.value = isFinite(e.loaded / e.total) ? e.loaded / e.total : 0;
|
||||
//});
|
||||
//xhr.send(fd);
|
||||
|
||||
ShowMessage("File upload started...");
|
||||
FileTransferProgress.value = 0;
|
||||
FileTransferProgress.parentElement.removeAttribute("hidden");
|
||||
|
||||
var strPath = "/API/FileSharing/";
|
||||
var fd = new FormData();
|
||||
for (var i = 0; i < fileList.length; i++) {
|
||||
fd.append('fileUpload' + i, fileList[i]);
|
||||
}
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', strPath, true);
|
||||
xhr.addEventListener("load", function () {
|
||||
FileTransferProgress.parentElement.setAttribute("hidden", "hidden");
|
||||
if (xhr.status === 200) {
|
||||
ShowMessage("File upload completed.");
|
||||
MainRc.RCBrowserSockets.SendSharedFileIDs(xhr.responseText);
|
||||
}
|
||||
else {
|
||||
ShowMessage("File upload failed.");
|
||||
}
|
||||
});
|
||||
xhr.addEventListener("error", () => {
|
||||
FileTransferProgress.parentElement.setAttribute("hidden", "hidden");
|
||||
ShowMessage("File upload failed.");
|
||||
});
|
||||
xhr.addEventListener("progress", function (e) {
|
||||
FileTransferProgress.value = isFinite(e.loaded / e.total) ? e.loaded / e.total : 0;
|
||||
});
|
||||
xhr.send(fd);
|
||||
}
|
||||
|
||||
function closeAllHorizontalBars(exceptBarId: string) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user