Code Monkey home page Code Monkey logo

Comments (3)

sandersdevelopment avatar sandersdevelopment commented on May 28, 2024 1

@diegomvh Thanks for your fast reply!

I can't find much about the odata standard itself regarding positing binaries, but in another projekt, we used the simple.odata.client in C# where they set a media stream like this:

https://github.com/simple-odata-client/Simple.OData.Client/blob/master/src/Simple.OData.Client.IntegrationTests/TripPinTests.cs#L1259

We have another self hosted odata api where we take the .Media().setStreamAsync() and interpret it like this:

serversideBinaryUpload

Since this works with the simple.odata.client I believe the standard says PUT on the $value endpoint

I will give your solution a try in a moment :-)

Btw: Is there any way to donate for this project? Since we think about using it in production, we'd love to do that.

Thanks :-)

Update: A colleague sent me this a few seconds ago :

https://github.com/simple-odata-client/Simple.OData.Client/blob/cc377a7e1d6a4399e6a4283030bac59e491f9905/src/Simple.OData.Client.Core/Fluent/RequestBuilder.cs#L70****

Does any of this help?

Update: Your solution (where we use PUT instead of POST) works, when we push the blob without any form data but with the application/octet-stream header!

from angular-odata.

diegomvh avatar diegomvh commented on May 28, 2024

Hi @sandersdevelopment

can you provide some data about de odata standars for posting blobs?, i google'ling for some of that

About your issue, you can allweys use the client with the full http primitives maped to the http client of angular but using resources.

const formData = new FormData();
formData.append("file", file);
const resource = this.client.entitySet<Object>(ENDPOINT).entity(Object.Id).value();
this.client.post(resource, formData);

The resource API tries to map the details of the standard, of course I will try to contemplate the possibility of posting data from the value resource. But at the moment, don't look too much on the internet about how the standard says what to do.

Thanks to you guys for posting the issue and taking the time to test the library.

from angular-odata.

diegomvh avatar diegomvh commented on May 28, 2024

Hi
Thank you for providing information to see the topic of the media.
One idea is to go back to the implementation of the media resource that the library had at some point, this would be:

# For Entity
this.client.entitySet<Object>(ENDPOINT).entity(Object.Id).media().fetchBlob().pipe(....)
# For Navigation
this.client.entitySet<Object>(ENDPOINT).entity(Object.Id).navigationProperty<Property>("Property").media().fetchBlob().pipe(....)

Unfortunately I find it difficult to find more information on the internet about how to implement the PUT and that it conforms to the standard, I don't quite understand if it is the correct way and how the implementation of server to receive the request.

I'm going to try something this way: "...we use PUT instead of POST) works, when we push the blob without any form data but with the application/octet-stream header!"

Could you please provide me with the call code using the client? Was it just writing the blob with the "application/octet-stream" header?
To start I see to create the media resource, I hope you can help me with the tests, I do not have the reception of streams implemented in my backend.

Thank you very much and I hope my request is not annoying.

Update: Did you try the mime type in the blob?
https://github.com/angular/angular/blob/e2aa7652e5270e2a0c825ee2f0dde8e307a3b959/packages/common/http/src/request.ts#L319

from angular-odata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.