objective-c odatasdk
I am consuming OData WCF Data Service in my iPad application. I am able to add a开发者_如何学Gon object to the Entity at my server side but unable to add NSData field to the SQL Server image data field.
I am not getting any error while adding and saving the object at remote side.
can you help me how can I send NSData type value to SQL server image data type field using OdataSDK ?
I managed to upload a byte[] (NSData) file by using the ODataSDK for Objective-C by configuring my OData service to provide a Stream Service Provider. I started from a Visual Studio project that had my SQL Server tables mapped with the Entity Framework, so that OData already exposed the entities to save/read to. It's important to note that the entity that has the file byte must have the m:hasStream attribute set in the Entity Framework .edmx file, which can be done only by manually editing the XML file (Have a look at this tutorial, which is made of three parts: here's the first )
Once you do so, the ODataSDK for ObjC provides the methods setSaveStream
(and getReadStream
) to save (and read) the NSData file (although I had some problems getting getReadStream to work, but it may be due to the fact that it was my first implementation of such service).
If you are uploading files larger than 64KB, have a look at this answer to properly configure your Web.config: https://stackoverflow.com/a/6907582/423816
Of course you also have to use the addObject:
and saveChanges:
methods, but this is what you'd do with any other OData entity.
Hope this helps
精彩评论