Coder Social home page Coder Social logo

FILE UPLOAD ISSUE about spark HOT 8 CLOSED

LumiProj avatar LumiProj commented on July 3, 2024
FILE UPLOAD ISSUE

from spark.

Comments (8)

kennethmyhra avatar kennethmyhra commented on July 3, 2024

I need more information regarding how you do file upload. POSTing Binaries to Spark has been tested and should work.

from spark.

LumiProj avatar LumiProj commented on July 3, 2024

Hi,
Thank you for your prompt response.I am using the latest of Spark version 1.5.14 and .Net core version 6.0 
I have a simple controller to upload files using the [FromForm] attribute as shown below.
[HttpPost, DisableRequestSizeLimit]
        public async Task<ApiResponse> UploadFile
( [FromForm] IFormFile formFile )
        {
         
            // Removed my code
            return null;
       
        }
Postman CURL script to use this method is.
curl --location --request POST 'https://localhost:44364/api/Document'
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI1NzYzZWQyYjQ0MGI0OTk4OWJlNGY1NjQyNGVkYzFlYiIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJqYW1pbGFrMjJAeWFob28uY29tIiwiZXhwIjoxODIyNzE3NzA5LCJpc3MiOiJYZWxsZSIsImF1ZCI6IlhlbGxlIn0.acSOpS1LHJSzgFxJXoQBnYAMicLSsNzWJZQBLeKR4s4'
--header 'Content-Type: multipart/form-data'
--form 'File=@"/F:/DCIM/105APPLE/IMG_5008.JPG"'
--form 'CreatedBy="9b12d575-a29a-436d-8677-c88997327a4f"'
--form 'DocumentType="Workbook"'

but when I submit the form I am getting an unsupported media type error.
I hope you got my issue, please help me out.
Thanks

from spark.

kennethmyhra avatar kennethmyhra commented on July 3, 2024

The code you are sharing do not have any relevance to FHIR APIs so I suspect there is some lack of understanding on how to interact with FHIR APIs

You can try the following curl command against my official test server. Create a text file called test.txt with some random content and run the following command:

curl --request POST --data-binary "@test.txt" https://spark.incendi.no/fhir/Binary

I recommend that you take a look at the examples I've put up, like this one: https://github.com/incendilabs/spark-example

from spark.

LumiProj avatar LumiProj commented on July 3, 2024

Hi,

Thank you again for the prompt response. Well I know there is a Binary resource where we can store all sorts of documents in binary format which is perfectly fine and it is working at my end as well, I don't have issues with it.

My client wanted to store all their documents in Mongo GridFS, For that purpose I created a separate controller to store and retrieve Documents in GridFS.

For more information I can share my complete project so you would have a clear understanding of my problem and it would help you help me out to resolve this issue.

Here is the complete project, please fill the MongoDB connection string inside appsettings.json.
https://github.com/lumisoftllc/MongoFhir

Below is the curl script to upload files in GridFS.

curl --location --request POST 'https://localhost:44364/api/Document'
--form 'File=@"/F:/DCIM/105APPLE/IMG_5008.JPG"'
--form 'CreatedBy="9b12d575-a29a-436d-8677-c88997327a4f"'
--form 'DocumentType="Workbook"'

Thanks

from spark.

LumiProj avatar LumiProj commented on July 3, 2024

Hi,

Please guys I am wailing for the response.

from spark.

kennethmyhra avatar kennethmyhra commented on July 3, 2024

We are overriding the formatters in the MVC pipeline which then interferes with your API at api/Document. The easiest way to get this to work is to move your DocumentController into a separate project. Then you will have one endpoint (project 1) which is pure FHIR APIs and another endpoint (project 2) where you can add your own APIs like the DocumentController API.

from spark.

LumiProj avatar LumiProj commented on July 3, 2024

Hi!

Thank you so much for the prompt response.

Well my task is to use the same end point for both Fhir and other custom controllers.
Anyhow I have achieved this behavior by sending the files in base64 and then converting into stream and store in GridFS.
Despite that, I appreciate your team for working on this amazing project.

from spark.

kennethmyhra avatar kennethmyhra commented on July 3, 2024

Thanks for saying that @LumiProj, that's appreciated

from spark.

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.