Archived from the Transloadit support forum. Originally posted on December 10, 2013; details may be outdated, see our docs for current behavior. Original thread
I have suggestions to implement transloadit with .Net.
It is exactly useful for .Net developer.
I created two class for Video and Image to use deserilize the Transload JSON data. (please find attached file.)
I wrote a function to deserilize the Json data.
public static T Deserialize(string json) { var obj = Activator.CreateInstance(); using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(json))) { var serializer = new DataContractJsonSerializer(obj.GetType()); obj = (T)serializer.ReadObject(ms); return obj; } }
*I am using Masterpage → I added “POST” method to Form tag in Masterpage.
I am using following Javascript for transload (I can upload Video and Image)
$(function () {
// We reference our html form here
$('form#Form1').transloadit({
// We want to wait for all encodings to finish before the form is submitted.
wait: true,
autoSubmit: true,
// The upload to Transloadit should start as soon as the user selects some files.
triggerUploadOnFileSelection: true,
params: {
auth: {
// This is your API key.
key: "REDACTED"
},
"onProgress": function (bytesReceived, bytesExpected) {
// render your own progress bar!
$('#progress')
.text((bytesReceived / bytesExpected * 100).toFixed(2) + '%');
},
"onError": function (assembly) {
alert(assembly.error + ': ' + assembly.message);
},
"onSuccess": function (assembly) {
alert(': ' + assembly.message);
},
"onResult": function () {
form.submit();
},
"onUpload": function (upload) {
alert("On Result");
},
// Our assembly instructions just contain two steps for now. You can name the steps whatever you want.
steps: {
"phone_video": {
robot: "/video/encode",
preset: "iphone",
width: 640,
height: 480,
ffmpeg: {
an: true
}
},
"image_thumbs": {
"use": ":original",
"robot": "/image/resize",
"format": "jpeg",
"width": 320,
"height": 240
},
"video_thumbs": {
"use": ":original",
"robot": "/video/thumbs",
"width": 320,
"height": 240,
"resize_strategy": "pad",
"background": "#000000",
"count": 1
}
}
}
});
});
</script>
and I added following code block to upload files.
Usage of Classes and Deserilize functions :
String transloadPost = Request.Form[“transloadit”]; if (transloadPost != “” && transloadPost != null) { if (transloadPost.Contains(“video”)) { TransLoadVideo.RootObject rootObj = new TransLoadVideo.RootObject(); rootObj = Deserialize(transloadPost);
}
else
{
TransLoadImage.RootObject rootObj = new TransLoadImage.RootObject();
rootObj = Deserialize<TransLoadImage.RootObject>(transloadPost);
}
}
BTW :
Please do not forget add transload scripts :