Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I have to send a byte array to an api along with the field data as shown in the figure.I have a doubt about using the modules provided by angularjs community because its not stating about how the data is transferred and I have little understanding about it. so I want to post any file uploaded from a button to a byte collection to an api with the form data. here is an image for my api.

enter image description here

Actually the problem I faced is changing the file to byte in angular and again finding a module to upload the byte array. I have seen some of byte uploading techniques but they are quit different compared to what I need.If you have some better ways to look at this please show me some

share|improve this question

Dagm,

I do not have enough points to add a comment to your question, so I will start an answer here.

I am using the .NET Web API 2.0 on the server to receive and process the client transmission. Is this an option for you?

I am sure that there are other server options other than Web API, but half of my answer depends on this server-side functionality.

Let me know, and I will try to assist you.

Regards....

I can at least give you some client code that works with angular. I do a lot of client side compaction and compression of data into byte arrays before sending to the server.

Let me know if this would be useful.

Here is some client code.

ItemHttpService.prototype.uploadItem = function ($http, Id, Transaction_Id, FileName, FileExt, File, itemUploadCallback) {
        $http({
            // Web API 2.0 specific. ItemUpload references the ItemUploadController. UploadItems is method name.
            url: 'api/ItemUpload/UploadItems',
            method: 'POST',
            headers: { 'Content-Type': 'application/octet-stream' },
            data: new Uint8Array(File),
            params: {
                // Other params here, including string metadata about uploads
                Id: Id,
                Transaction_Id: Transaction_Id,
                FileName: FileName,
                FileExt: FileExt
            },
            transformRequest: [] // Used to handle the byte array data.
        }).success(function (response, status) {// This is one example of how I handled a response.
            if (status === 200) {
                itemUploadCallback(response); // As I recall, the response is a JSON stringified result. 
            } else {
                itemUploadCallback('');
            }
        }).error(function (status) {
            itemUploadCallback(JSON.stringify("Your error handling here"));
        });
    };

Not sure what the tblPeriodical_Transaction is. Can you elaborate?

share|improve this answer
    
After taking some of you adjustment and tbl_transaction as a json param it go me going some how ,thanks – Dagm Fekadu Jul 27 at 7:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.