Is there any way to manually initiate an AJAX upload with the Kendo Upload control - kendo-ui

I am doing an upload via CORS to Amazon S3 with the Kendo Upload control. I'm having an issue with the fact that I need to grab a signature from my server, then add it to the 'data' for the event object of 'upload' handler I created. The problem is, of course, that in the handler I fire off an async request to get the signature, and the upload handler continues on it's merry way without the signature data i need. The published API has no 'upload()' or something command that I could call when my async request returns.
I saw an ASP-Kendo-S3 example somewhere, but it's not exactly clear from that code, how that signature is being obtained, and of course, I'm not using ASP.

Kendo Upload has an onUpload event. In Kendo's asp.net example there really isn't anything specific to that framework that wouldn't port to anything else.
They populate the page initially with the profile (base64 encoded JSON).
To get a signature for that base64 encoded json profile they use this method (C#):
private static string Sign(string text, string key)
{
var signer = new HMACSHA1(Encoding.UTF8.GetBytes(key));
return Convert.ToBase64String(signer.ComputeHash(Encoding.UTF8.GetBytes(text)));
}
It looks pretty self explanatory to the point where you could port it to another language.

Related

How to call an external API in truclient protocol of loadrunner

I am recording a script using truclient protocol.In my script ,i need to externally call an API which generates the Password. The password is fetched using the co-relation,which is used as an input for Login.
I am however unable to call the external API using the true client protocol.
Could anybody please suggest how to call an external API in true client protocol.
Have you tried the evaluate JavaScript step? You can post the message to the server and get the generated password during the runtime. XHR and fetch API should be supported in Chrome and Firefox, TCIE should support XHR.
Sure. Please check the detail steps:
Drag and drop an evaluate JS step from TruClient
Open the script editor
Add these code, make sure use the sync XHR to ensure the password is returned before the end step started:
var xhr = new XMLHttpRequest();
xhr.open("POST", '/server', false);
//Send the proper header information along with the request
xhr.setRequestHeader("xxx", "value");
xhr.send();
if (this.status === 200) {
// Request finished. Do processing here.
}
var password = xhr.response;
Change the login password step from plain text to JS and use
ArgsContext.password
to reference the previous received password.
If you have another questions please let me know. How to use the argument context you could reference this link.
BTW. the window and document object of the page can be referenced with AUT.window, AUT.document in TruClient.
Please check the help document from here.

Outlook Add-in file reading from mail

I am working on a Outlook add-in. I am not able to use the method item.getAttachmentsAsync in my plugin code to load and read the content of files.
I am getting ERROR TypeError: item.getAttachmentsAsync is not a function in run time.
var item = Office.context.mailbox.item;
var options = {asyncContext: {currentItem: item}};
item.getAttachmentsAsync(options, this.callback);
My requirement is explained below,
In the plugin we have a form and few fields are populated from mail body.
And I need mail attachments to auto upload to Form.
Please suggest a better way to do that.
using getAttachmentContentAsync I am able to get the file as a blob. but the problem is we need to call this method as soon after the mail opening. otherwise getting cors error

How to send an email with multiple attachments from Gmail using API client library for .NET

My app uses Google API client library for .NET to send emails with attachments.
When using Send(), I'm facing some limitations when it comes to file size of the attachments. So, I guess switching to Resumable upload as upload method may help. But it's pretty much undocumented.
Looking into source code, I guess using different Send() overload may be the way forward, but I can't figure out how to use it properly.
So, instead of attaching the files into message and calling it like this:
var gmailResult = gmail.Users.Messages.Send(new Message
{
Raw = base64UrlEncodedMessage
}, "me").Execute();
I should not attach the files to message and do something like following?
var gmailResult = gmail.Users.Messages.Send(new Message
{
Raw = base64UrlEncodedMessage
}, "me", fileStream, contentType).Upload();
The second version does not return any API error, but does nothing. I'm obviously missing something here.
How do I attach more than one attachment?
This is kind of an old question, but putting an answer here just in case anyone else needs it:
I was able to achieve this by converting my mime message into a stream (attachment(s) included), and then calling this overload on Send:
UsersResource.MessagesResource.SendMediaUpload googleSendRequest = service.Users.Messages.Send(null, "youremail#gmail.com", mimeMessageStream, "message/rfc822");
IUploadProgress created = googleSendRequest.Upload();
This will upload all of the attachments with the email message content and then send it off. I was able to send two 5 megabyte attachments in an email. Previously I was not able to send even one of those via the other Send method that takes in a base64 encoded mime message.

Setting UUID manually

My server generates UUID for uploaded files, so i need to set UUID to the fileState after i received answer from upload server (to successfully use delete function). I added and implemented
setUuid: function(id, uuid)
In UploadHandler, FineUploaderBasic and UploadHandlerXhr to solve this issue but this involve editing fine-uploader sources, is there any other way around? I have feeling this can break something internally.
I would suggest not passing the UUID back to fine uploader. It would be simpler to associate your UUID with fine uploader's UUID server side. You could maintain a map of associations in the session if you don't want to persist them.
I encountered this issue and found some documentation that states you can set the UUID from the server side by returning it from the upload method.
click image where newUuid is being set
Here is my return method using C#
return new FineUploaderResult(true, new { newUuid = attachmentId });

Loading and saving JSON files in a GWT web application

We are developing an GWT web-application with an Python webapp2 webserver. At this point we want to load and save files within the web-application. We cannot use Flash for this task.
Saving
The current approach is to use a form upload using the target "_blank" and set the correct MIME to make the browser download the file. This solution works, but since the webapp2 webserver does not support streaming (thus the mime type cannot be validated by the browser in a short time), a new browser-window is opened each time. Is there a better solution e.g. using iFrames?
Loading
Again using form upload and parsing the response (JSON). We use the content-type "text/html; charset=UTF-8". This solution works perfectly in IE9 but does not work in Chrome and FireFox. It seems, that the JSON response gets corrupted in some way or is there anything from when parsing a JSON response from a form upload response? We use piriti for JSON (de)serialization.
For loading, you can use RestyGWT library, it has capability encoding or decoding Java Object to JSON:
import javax.ws.rs.POST;
...
public interface PizzaOrderCodec extends JsonEncoderDecoder<PizzaOrder> {
}
// GWT will implement the interface for you
PizzaOrderCodec codec = GWT.create(PizzaOrderCodec.class);
// Encoding an object to json
PizzaOrder order = ...
JSONValue json = codec.encode(order);
// decoding an object to from json
PizzaOrder other = codec.decode(json);
For saving, if you have to send JSON file using file upload, you can see following link:
http://www.jroller.com/hasant/entry/fileupload_with_gwt
http://www.celinio.net/techblog/?p=1207
Have a nice time.

Resources