I've been searching around the web for a long time but I couldn't find something specific about the best approach for this architecture issue.
I have an upload pattern that derives from Amazon which has two POST Api calls, the first sends the binary file returning its ID and then I have the second Api that sends the metadata combined with the location ID for this file where I can treat this in server side. I have this well implemented and managed inside my client.
However, now I want to GET this binary file together with the metadata, but I'm not sure if this two Api model is the best approach to handle inside the client. Maybe it has a content-type like Multipart, but I never know which metadata and how many files I will return. I also don't want to return in a Base64 because we are supposed to deliver contents more than 10mb and this would lack performance.
I was wondering about how Google, Amazon, Dropbox,etc deal with this with their APIs.
So, I'm quite new to the ASP.NET MVC framework. What I need to do is make an API endpoint for a webserver which accepts a HTTP post request that has an image file uploaded to it.
I've looked around and I'm really not sure how to handle this. The closest I've come is this resource:
File Upload and Multipart MIME - ASP.NET Web API
Is this pretty much the only way to do it?
No, you can also send it across as a class that has a string property that contains the base64 encoded contents of the file. You then have to decode the base64 in the web api method (which is still a post) and then save or use the file bytes.
From the client's stand point, the most straight-forward way of doing it is multipart mime. But your question was about web api, and it can handle base64 in say, a json object just fine.
If you don't use multipart mime you'll need javascript that converts the upload into base64. That part of it is beyond the scope of your question.
But strictly speaking multipart is not the only way because I had such a javascript file upload library and that's what I used and it worked fine.
The reason why we used that component was because we wanted thumbnail upload preview of the images (preview first), then a submit button to actually submit to web api. javascript held the images in localstorage until the user hit submit (was a multiple image upload thing).
I am transfering a large zipped text file over the classic asmx web service.
My reason for doing so is that the file's size is 20 MB unzipped, 4MB zipped.
This is the method. I will provide additional information if necessary.
[WebMethod]
public byte[] Transfer()
{
return File.ReadAllBytes(#"4MBFile.zip");
}
I am using C# and .NET 4. (I changed the initial settings for the project from 2.0 to 4.0).
A webmethod uses a kind of serialization so I guess there will be some overhead.
Am i really transferring only 4MB?
How do I measure this overhead, if there is any?
XML Web Services expose useful functionality to Web users through a standard Web protocol. In most cases, the protocol used is SOAP.
This question shows that the XmlSerializer, used by ASMX Web Services, by default Base64-encodes binary data , so yes, the overhead will be noticable.
Am I really transfering only 4MB?
What keeps you from monitoring a service call using Fiddler? It'll tell the exact HTTP response body size.
There seems to be a solution by attributing the property as hexBinary, so it won't be Base64-encoded.
There is a need to develop some "Service" program that will receive and process BLOB data from Oracle DB server. The clients will be written in Delphi 2010. I have freedom of choice that technologies I will use to produce server part of this project. And that's why I have posted this question here. Could you guys point me some blog posts, articles, forums where I can get various information about creating such type of services? I have an experience with Microsoft's WCF services, but it has bas intergration with Delphi clients via WSDL. Now I stopped on ASMX Web Service written in C# and need to get some samples how can I transfer BLOB data between server and client. It would be better if server and client communicating thru raw socket, instead of incapsulation all data in SOAP. Thanks in advance and strongly hope for you help, guys!
I would recommended you to use RemObjects SDK for develop server & client web services applications, it has many features not available on Delphi & .Net, also they support different messaging, so you can use binary message instead of SOAP to transfer the BLOB data, which is much faster and more compact.
They also .Net version of server and client so you can mix between them.
A nice and standard way of handling BLOB fields is the REST protocol.
Thanks to the REST protocol, you can GET, POST, PUT or DELETE a binary BLOB from its URI. That is, if your URI is dedicated to the BLOB field, you'll be able to use raw binary transmission, and no MTOM or Base64 transmission.
For instance, you can get a BLOB content with ID=123 with a GET at such an URI:
http://servername/service/123/blob
It will work also from a standard web browser. So if the BLOB is a picture, it should be displayed directly in the browser.
With a POST at the same URI, you add a new blob, or with a PUT you update the blob. With a DELETE verb... you delete it. This is what RESTful means over HTTP.
This is, for instance, how our mORMot framework works. It is also able to fast have direct access to the Oracle database on the server side, with some dedicated classes. What is nice with such an ORM-based framework, is that high-level clients can use objects, and handle much more than only BLOBs, and that it handles URL-level security and authentication.
But you can easily write your own service using some units available in mORMot, if you don't need the whole RESTful ORM feature:
For a fast http.sys based HTTP/1.1 server, take a look at SynCrtSock;
For the HTTP/1.1 client access, the same SynCrtSock unit defines some client classes;
For very fast direct access to Oracle, see SynOracle.
This is all Open-Source, working from Delphi 5 and later. There is a lot of documentation available (more than 600 pages), including high-level presentation of such concepts as REST, ORM or n-Tier.
This is fairly high-level, but so is the question:
If it is a "raw socket" it isn't really a "web service"; although there is of course the middle ground of REST or a HTTP POST.
If you are looking at a web-service, and the data is non-trivial, then you probably want to look at MTOM to avoid the base-64 overhead (which is supported in WSE 3, or (simpler) WCF via basicHttpBinding). I would expect most tools to have a reasonable comprehension of a basic web-service with MTOM.
if you want to expose some data in a data base (in this case blob data in oracle) as a web services WSO2 DSS[1] provides an easier solution. This is under Apache license and it is available for free. Since all the WSO2 Products are based on WSO2 carbon platform the services you create supports MTOM, WS-Security and other Web service related features as well.
[1] http://wso2.org/library/dss
I am new to .net. I created one website.I want to implement Zlib compression technique for compressing data in each every page, so that i can access open my website quickly.But i don't know where I have to write code for that and how to implement it. Can yo send me the sample application code or zip file.
If your talking about compressing web pages delivered from the server then gzip is used.
IIS6 Example