-
Notifications
You must be signed in to change notification settings - Fork 156
Stuck on upload #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
OMG, guys, really? Could someone please fix this? The solution is the type, see |
@PArns Can you provide a sample for us to clone and reproduce your issue? |
Hey @superkhau, yes of course! You can find a demo project here: https://github.com/PArns/loopback-stuck-test And the following Postman settings (under body, add a file called "file"): If you switch from "Content-Type" to "Accept", the upload works without any problems. But as a user could post nearly everything, this will break the whole server! |
Hey @superkhau, are you able to reproduce the bug? |
@PArns Not yet, haven't had time to reproduce it yet -- @raymondfeng Do you see anything obvious here? |
@PArns Your code has a bug at https://github.com/PArns/loopback-stuck-test/blob/master/common/models/attachement.js#L10. Please change it to be |
Hello @raymondfeng, please have a look at the console output:
Maybe the callback is not called correctly, but that doesn't fix the error! The time between the DO log and the FILE log is around 30 seconds. At a certain point in time Postman cancels the request due to a timeout (but that also occurs before FILE is printed!!). Just check out my code and try it with Postman |
I assume you have created |
Again, please test it with Postman and the Header "Accept: multipart/formdata" |
@raymondfeng Raymond, you're totally right ... I'm stupid, sorry ;) |
@PArns Glad you got it resolved, is this good to close? You can create another issue for the header exception with descriptions, steps to reproduce etc. |
Yes, sure ... Thx for your input |
I'm facing the issue with either 'Accept' or 'Content-Type' headers set. It is working without any of those though. I hope there isn't an issue if I continued without using either of the headers. |
"The solution to the content type problem problem is to explicitly set Content-Type to undefined so that your browser or whatever client (like postman) you're using can set it and add that boundary value in there for you. Disappointing but true." - checkout this link for more details - https://stackoverflow.com/questions/39280438/fetch-missing-boundary-in-multipart-form-data-post/39281156#39281156 |
hello there, i have the same problem. Upload is working fine using postman, but with axios i get following error Error: Request aborted |
I face the same problem, I use const formData = new FormData();
formData.append('file', file);
const { data } = await axios.post(${url} ,{ formData },
{
headers: {
'Content-Type': undefined,
},
},
);
return data; and I have an import Cookies from 'js-cookie';
import axios from 'axios';
const axiosInterceptors = store => {
axios.interceptors.request.use(config => {
const newConfig = Object.assign(
{},
{
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
},
config,
);
const csrfToken = Cookies.get('XSRF-TOKEN');
const { authentication } = store.getState();
if (authentication.data && authentication.data.id) {
newConfig.headers.Authorization = authentication.data.id;
}
if (csrfToken) {
newConfig.headers['XSRF-TOKEN'] = csrfToken;
}
return newConfig;
});
};
export default axiosInterceptors; But when I tried to upload file in backend using
|
This quick fix in server.js works for me.
storage component should check if files already uploaded by mutter and body parser then doesn't use formidable. |
I've a very simple server running under loopback 3 and seeing this issue again: #9
As the gists and examples don't work any longer I would like to reopen that issue.
I've created a very simple API templated server and added the following code:
The problem is now, that while posting via POSTMAN to the upload function, I see the following behavior in the console:
And Postman returns an empty response...
I'm totally lost as a beginner here at this step!
What is my fault here?
Thx for any input
The text was updated successfully, but these errors were encountered: