public bool Execute(IBackloadContext context, IOutgoingResponseParam param) { // Important Note: Since Version 1.9 PlUpload can be handled internally (Plugin attribute in the configuration). // Don't forget to rebuid the extension if you made changes to your extension, otherwise you may use the old extension assembly. if (context.RequestType == RequestType.Default) { var result = new PlUploadFiles(); foreach (var file in param.FileStatus.Files) { if (context.HttpMethod != "DELETE") { result.files.Add(new PlUploadFile(file.Success, file.FileName, file.FileSize, file.ContentType, file.DeleteUrl, file.ThumbnailUrl, file.FileUrl, file.ErrorMessage)); } else { result.files.Add(new PlUploadFileCore(file.Success, file.FileName, file.ErrorMessage)); //We only return values we need on client side, so we return a PlFileCode object } } param.Result = Helper.Json(result); return(param.FileStatus.Files.Count > 0); // we have processed the response, so we notify the pipeline } return(false); }
public bool Execute(IBackloadContext context, IOutgoingResponseParam param) { // Note: We use convention based plugin handling (see Example 09). // Backload v1.9 and above can handle this internally. Just send plugin=plupload in the querystring or in the config file. // // In our example we have a PlUpload Plugin client side, so we transform the output to a PlUpload friendly format. // Important Note: Since Version 1.9 PlUpload can be handled internally (Plugin attribute in the configuration). // // Remarks: Don't forget to rebuild your solution if you made changes to your extension, otherwise you may use the old extension assembly. if (param.FileStatus == null) { return(false); // in the case something went wrong. } var result = new PlUploadFiles(); foreach (var file in param.FileStatus.Files) { if (context.HttpMethod != "DELETE") { result.files.Add(new PlUploadFile(file.Success, file.FileName, file.FileSize, file.ContentType, file.DeleteUrl, file.ThumbnailUrl, file.FileUrl, file.ErrorMessage)); } else { result.files.Add(new PlUploadFileCore(file.Success, file.FileName, file.ErrorMessage)); //We only return values we need on client side, so we instatiate a PlFileCore object } } param.Result = Helper.Json(result); return(true); // We've processed the response }
public bool Execute(IBackloadContext context, IOutgoingResponseParam param) { // IMPORTANT NOTE: // Backload v1.9 and above can handle PlUpload internally now. Just send plugin=plupload. You do not need an extension anymore. // // In our example we have a PlUpload Plugin client side, so we transform the output to a PlUpload friendly format. // Important Note: Since Version 1.9 PlUpload can be handled internally (Plugin attribute in the configuration). // We have two upload plugins in our form, but this extension is only for PlUpload. We have two options to ensure that our // extension only handles PlUpload requests: Convention based handling or conditional handling. // In our example we use handling based on convention, where the convention is: // 1. In our request we set a "plugin" querystring to plupload (plugin=plupload) // 2. The namespace of our extension contains Plugin.PlUpload (not case sensitive) // If you do not want to use convention based handling, just do not send a "plugin" querystring or leave it empty (plugin=) // // You may use conditional handling instead. The extension code is called, and you make the decision based on a condition // if to handle the request or not in your code. Typically you parse the request (Querystring or body) for a condition: // Example: // string control = context.Request.QueryString["control"]; // if ((string.IsNullOrEmpty(control)) || (control != "plupload")) return false; // // Remarks: Don't forget to rebuild your solution if you made changes to your extension, otherwise you may use the old extension assembly. if (param.FileStatus == null) { return(false); // In case something went wrong } if (context.HttpMethod != "DELETE") { var result = new PlUploadFiles(); for (int i = 0; i < param.FileStatus.Files.Count; i++) { var file = param.FileStatus.Files[i]; result.files.Add(new PlUploadFile(file.Success, file.OriginalName, file.FileSize, file.ContentType, file.DeleteUrl, file.ThumbnailUrl, file.FileUrl, file.ErrorMessage)); } param.Result = Helper.Json(result); } else { // Here we use an anonymous type to return some data. PlUpload does not handle server side file deletion, but we made the // ajax request and so we can return whatever we want. var file = param.FileStatus.Files[0]; var result = new { success = file.Success, message = file.ErrorMessage, name = file.FileName }; param.Result = Helper.Json(result); } return(param.FileStatus.Files.Count > 0); // if > 0 we've changed properties. }
public bool Execute(IBackloadContext context, IOutgoingResponseParam param) { // IMPORTANT NOTE: // Backload v1.9 and above can handle PlUpload internally now. Just send plugin=plupload. You do not need an extension anymore. // // In our example we have a PlUpload Plugin client side, so we transform the output to a PlUpload friendly format. // Important Note: Since Version 1.9 PlUpload can be handled internally (Plugin attribute in the configuration). // We have two upload plugins in our form, but this extension is only for PlUpload. We have two options to ensure that our // extension only handles PlUpload requests: Convention based handling or conditional handling. // In our example we use handling based on convention, where the convention is: // 1. In our request we set a "plugin" querystring to plupload (plugin=plupload) // 2. The namespace of our extension contains Plugin.PlUpload (not case sensitive) // If you do not want to use convention based handling, just do not send a "plugin" querystring or leave it empty (plugin=) // // You may use conditional handling instead. The extension code is called, and you make the decision based on a condition // if to handle the request or not in your code. Typically you parse the request (Querystring or body) for a condition: // Example: // string control = context.Request.QueryString["control"]; // if ((string.IsNullOrEmpty(control)) || (control != "plupload")) return false; // // Remarks: Don't forget to rebuild your solution if you made changes to your extension, otherwise you may use the old extension assembly. if (param.FileStatus == null) return false; // In case something went wrong if (context.HttpMethod != "DELETE") { var result = new PlUploadFiles(); for (int i = 0; i < param.FileStatus.Files.Count; i++) { var file = param.FileStatus.Files[i]; result.files.Add(new PlUploadFile(file.Success, file.OriginalName, file.FileSize, file.ContentType, file.DeleteUrl, file.ThumbnailUrl, file.FileUrl, file.ErrorMessage)); } param.Result = Helper.Json(result); } else { // Here we use an anonymous type to return some data. PlUpload does not handle server side file deletion, but we made the // ajax request and so we can return whatever we want. var file = param.FileStatus.Files[0]; var result = new { success = file.Success, message = file.ErrorMessage, name = file.FileName }; param.Result = Helper.Json(result); } return (param.FileStatus.Files.Count > 0); // if > 0 we've changed properties. }
public bool Execute(IBackloadContext context, IOutgoingResponseParam param) { // Important Note: Since Version 1.9 PlUpload can be handled internally (Plugin attribute in the configuration). // Don't forget to rebuid the extension if you made changes to your extension, otherwise you may use the old extension assembly. if (context.RequestType == RequestType.Default) { var result = new PlUploadFiles(); foreach (var file in param.FileStatus.Files) { if (context.HttpMethod != "DELETE") result.files.Add(new PlUploadFile(file.Success, file.FileName, file.FileSize, file.ContentType, file.DeleteUrl, file.ThumbnailUrl, file.FileUrl, file.ErrorMessage)); else result.files.Add(new PlUploadFileCore(file.Success, file.FileName, file.ErrorMessage)); //We only return values we need on client side, so we return a PlFileCode object } param.Result = Helper.Json(result); return (param.FileStatus.Files.Count > 0); // we have processed the response, so we notify the pipeline } return false; }
public bool Execute(IBackloadContext context, IOutgoingResponseParam param) { // Note: We use convention based plugin handling (see Example 09). // Backload v1.9 and above can handle this internally. Just send plugin=plupload in the querystring or in the config file. // // In our example we have a PlUpload Plugin client side, so we transform the output to a PlUpload friendly format. // Important Note: Since Version 1.9 PlUpload can be handled internally (Plugin attribute in the configuration). // // Remarks: Don't forget to rebuild your solution if you made changes to your extension, otherwise you may use the old extension assembly. if (param.FileStatus == null) return false; // in the case something went wrong. var result = new PlUploadFiles(); foreach (var file in param.FileStatus.Files) { if (context.HttpMethod != "DELETE") result.files.Add(new PlUploadFile(file.Success, file.FileName, file.FileSize, file.ContentType, file.DeleteUrl, file.ThumbnailUrl, file.FileUrl, file.ErrorMessage)); else result.files.Add(new PlUploadFileCore(file.Success, file.FileName, file.ErrorMessage)); //We only return values we need on client side, so we instatiate a PlFileCore object } param.Result = Helper.Json(result); return true; // We've processed the response }