I use QuickBlox api. I make a request for Declaring file uploaded.
Picture is displayed on the server, but in response Unexpected ''
my request in postman
Related
I am currently working on a application with React as frontend and Nodejs as backend.
I am using multer and minIO to store the files.
Currently:
I have a form where the user fills up some data and also has the option to upload files such as PDF/JPEG etc (multiple input fields for file).
I am using forkmik along with material UI for validation and styling.
So when a user fills up the form (data is a json object), if there is any file upload done it does a POST request to "/upload" uploads the file to the storage engine and then returns a path of where the file is stored.
Then I send one more POST request to "/" to save the user info along with the path that it returned earlier onto MongoDB.
I trying to make it as a single post request to "/" but cannot do so, this is what I have tried,
is to send the user info with content-type "multipart/form-data" along with the files, I am only able to get the "req.files" array properly while the "req.body" of the user information is shown as "[Object: null prototype] { 'values.general_information.first_name': 'Amy',
'values.general_information.last_name': 'John' }" and so on.
I am trying to receive it in a proper json format but cannot do so.
Since the data I was receiving was [Object: null prototype], in the body converted to string using JSON.stringify() and on the backend parsed the incoming data using JSON.parse(), without using react FormData and was able to make it into a single POST request using multipart/form-data as I was uploading files as well.
front-end is served from http://localhost:3000/
I want to access the JSON data which is inside a directory's file
by sending HTTP requests at same-origin http://localhost:3000/
in React.js
is it possible to do that, if it is so, how?
Yes, you have 2 solutions:
import the JSON file
fetch the JSON file from the project (like an external API) see this question for more details about the implementations
I have a React JS application where I send a GET request with axios. In the browser, in the Response Headers section, when I send the request I get Content-Disposition: attachment;filename="image123.pdf", but when I try to get this in React, I don't get any field with this name. So when I try to access the response.headers['content-disposition'], I don't get anything.
Is it possible to read this header key using React JS using axios?
So i'm trying to upload pdf files to directus. In postman it's working fine and uploads successfully on my React project i keep getting "You are not allowed to upload files. What am I doing wrong?
Could be cors problem
Could be that you overwrite your token via postman
From the official Directus API Docs:
By default, all data in the system is off limits for unauthenticated users. To gain access to protected data, you must include an access token with every request.
Source: https://docs.directus.io/api/authentication.html
I don't know how your project is structured, but if you're already authenticated within your (Web)app and want to upload using Axios or similar, you should pass the temporary or static token that you've already got to the library or method that sends the file (Header -> Authorization: bearer xxtokenxx).
If you still have questions, the documentation link above has everything you need.
I have problems to upload attachments to JIRA REST API using HTTP POST with the HTTP action. It works with text files (Content-Type: text/plain) but when I'm posting other files such as PDF and images the files are not uploaded correctly; they get the wrong file size and are not readable.
I assume it's a problem with the encoding. I've tried to use the binary function on the file contents but it does not help. According to JIRA the REST API doesn't accept base64-encoded files.
Have anyone of you been successful in posting attachments (other than text files) to JIRA or another API?
I found how to do it. The body of the HTTP request should contain special attributes for Multipart and Content-Type as described here: https://learn.microsoft.com/en-us/azure/connectors/connectors-native-http#content-with-multipartform-data-type
So the HTTP POST should look like this: