我创建了一个api,该api可以上传PPT并将ppt转换为视频并生成其缩略图,它可以很好地处理大型文件,但是在大型文件的情况下会完全失败。长时间运行的linux进程不会导致任何错误,但会导致前端(axios)的延迟(待定)
反应前端
def home(request):
posts = Post.objects.get(title='that title you want to use')
posts2 = Post.objects.get(title='that second title you want to use')
and...
search_query = request.GET.get('q')
if search_query:
posts = posts.filter(
Q(title__icontains = search_query) |
Q(content__icontains = search_query)
)
context={
'posts': posts
}
return render(request,'blog/home.html', context)
Nodejs后端
const config = {
onUploadProgress: (progressEvent) => {
var uploadedBytes = progressEvent.loaded;
var totalBytes = progressEvent.total;
// console.log(timecontroller);
var percentCompleted = Math.round(
(progressEvent.loaded * 100) / progressEvent.total
);
const copy = { ...this.state.uploadProgress };
copy[file.key] = {
state: "pending",
percentage: percentCompleted,
};
// Time Remaining
var seconds_elapsed =
(new Date().getTime() - timeStarted.getTime()) / 1000;
var bytes_per_second = seconds_elapsed
? uploadedBytes / seconds_elapsed
: 0;
var Kbytes_per_second = bytes_per_second / 1000;
var remaining_bytes = totalBytes - uploadedBytes;
var seconds_remaining = seconds_elapsed
? remaining_bytes / bytes_per_second
: 0;
// copy[file.key][file.key] = `${moment.duration(seconds_remaining).humanize()} left`;
copy[file.key][file.key] = `${humanizeDuration(
this.convertToMS(Math.ceil(seconds_remaining))
)} left`;
copy[file.key]["time"] = seconds_remaining;
this.setState({ uploadProgress: copy });
},
requestId: file.key,
timeout: 0
};
const response = await axios.post("/api/content", formData, config).catch(function(error) {
if (!error.status) {
// network error
}
});
在linux实例(Ubuntu)中运行linux进程时,我如何发布POST请求?