mediaUpload/uploadedVideo Returns 504 网关经常超时
mediaUpload/uploadedVideo Returns 504 Gateway Timeout frequently
通过 API 将视频上传到 LinkedIn 时,我们经常遇到 504 超时错误。我们添加了退避和重试机制,但仍然会因此而导致很大比例的失败。我们可以手动重试上传,最终他们无需更改任何内容即可正常工作。
还有其他人解决这个问题吗?我们可以对上传做些什么来减少或防止这些错误?下面是我们的一些上传代码:
data = self.session.post(
url="/assets",
params={"action": "registerUpload"},
json={
"registerUploadRequest": {
"owner": owner,
"recipes": ["urn:li:digitalmediaRecipe:feedshare-video"],
"serviceRelationships": [
{"identifier": "urn:li:userGeneratedContent", "relationshipType": "OWNER"}
],
"supportedUploadMechanism": ["SYNCHRONOUS_UPLOAD"],
}
},
)
upload_url = data["value"]["uploadMechanism"][
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest"
]["uploadUrl"]
response = self.session.put(
url=upload_url,
headers={"Content-Type": "application/binary"},
data=media.file.open("rb"),
return_response=True,
)
我们一直遇到同样的问题,对我们有用的是从 registerUploadRequest 中删除 supportedUploadMechanism
选项。
所以更新后的 JSON 应该如下所示
"registerUploadRequest": {
"owner": owner,
"recipes": ["urn:li:digitalmediaRecipe:feedshare-video"],
"serviceRelationships": [
{"identifier": "urn:li:userGeneratedContent", "relationshipType": "OWNER"}
]
}
通过 API 将视频上传到 LinkedIn 时,我们经常遇到 504 超时错误。我们添加了退避和重试机制,但仍然会因此而导致很大比例的失败。我们可以手动重试上传,最终他们无需更改任何内容即可正常工作。
还有其他人解决这个问题吗?我们可以对上传做些什么来减少或防止这些错误?下面是我们的一些上传代码:
data = self.session.post(
url="/assets",
params={"action": "registerUpload"},
json={
"registerUploadRequest": {
"owner": owner,
"recipes": ["urn:li:digitalmediaRecipe:feedshare-video"],
"serviceRelationships": [
{"identifier": "urn:li:userGeneratedContent", "relationshipType": "OWNER"}
],
"supportedUploadMechanism": ["SYNCHRONOUS_UPLOAD"],
}
},
)
upload_url = data["value"]["uploadMechanism"][
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest"
]["uploadUrl"]
response = self.session.put(
url=upload_url,
headers={"Content-Type": "application/binary"},
data=media.file.open("rb"),
return_response=True,
)
我们一直遇到同样的问题,对我们有用的是从 registerUploadRequest 中删除 supportedUploadMechanism
选项。
所以更新后的 JSON 应该如下所示
"registerUploadRequest": {
"owner": owner,
"recipes": ["urn:li:digitalmediaRecipe:feedshare-video"],
"serviceRelationships": [
{"identifier": "urn:li:userGeneratedContent", "relationshipType": "OWNER"}
]
}