simple-odata-client / Simple.OData.Client

MIT License
329 stars 196 forks source link

Creating Media Link Entries (MLEs) #227

Open coolOrange-Public opened 8 years ago

coolOrange-Public commented 8 years ago

It would be nice to have the possibility to create Media Link Entries (MLEs) via POST requests, in order to upload e.g files . In addition it should also be possible to pass data in the slug header as defined in AtomPub, section 9.7.

See: Topic: 2.5 Creating Media Link Entries (MLEs) http://www.odata.org/documentation/odata-version-2-0/operations/

object commented 8 years ago

This is planned for version 5.0 (which can be previewed if you compile 'master' branch from sources).

phatcher commented 8 years ago

Can I ask if this will be supported by V3?

object commented 8 years ago

Everything that is supported by the protocol should be supported. I don't remember without looking it up whether there are some differences between V3 and V4 support for media link entries but I will try to updated both adapters.

phatcher commented 8 years ago

Any timeline on V5 - I'm working around lack of streams with actions/functions but it would simplify my code

object commented 8 years ago

I would actually benefit from somebody testing this stuff. I will inspect the code and hope to release beta within a couple of weeks.

phatcher commented 8 years ago

If you can do a prerelease nuget package that would be great - I can update a couple of my solutions to use that

object commented 8 years ago

I'll be away for 10 days from tomorrow, but I will try to pre-release a package tonight. Very very alpha :-)

object commented 8 years ago

Unfortunately I don't have time to test and build 5.0 alpha NuGet packages now, so I will have to come back to it in 10 days. But if you want to try the next major update, you can pull master branch (4.x NuGet packages are built from v4 branch). It will give you basic idea about new features, there are integration tests for media links.

phatcher commented 8 years ago

Any update on the timeline for MLE support

object commented 8 years ago

I recently released an alpha version of 5.0, you can give it a try. Look at TripPin integration tests for example of media links.

enny1170 commented 8 years ago

I'm testing with the 5.0 pre nuget for uploading a file to my service. lokks god, but every time im get a "Simple.OData.Client.WebRequestException" with "Bad Request" and Message "$value kann nicht auf eine Auflistung angewendet werden." ($value may not applied to a list).

I'm try to create a new MLE with fallowing code var client = CreateClient(); IFile MediaFile = await FileSystem.Current.GetFileFromPathAsync(attachment.FileName); var stream = await MediaFile.OpenAsync(FileAccess.Read); // Create a PUT Request (adding a new image await client.For("PerfTestFieldAttachments").Set(new { CropId = attachment.CropId, Year = attachment.Year, LocationId = attachment.LocationId, FieldId = attachment.FieldId, X = attachment.X, Y = attachment.Y, RowNum = attachment.RowNum, SampleId = attachment.SampleId, FileName = MediaFile.Name, ContentType = attachment.ContentType, Id = 0 }).Media().SetStreamAsync(stream, "image/jpeg", true); Is this the right way or a problem in the client ?

object commented 8 years ago

Hi, Your code looks good as far as I can see. I will have to investigate this (next week unfortunately, I am travelling this week) and get back to you if I need more details.