增加本地推上传

This commit is contained in:
18610128193
2026-06-26 17:14:55 +08:00
parent cf1ca2be12
commit 4f2be8a137
4 changed files with 107 additions and 9 deletions
+27 -6
View File
@@ -277,6 +277,20 @@ async def _upload_to_juliang(
else:
filename = os.path.basename(storage_path)
#查询授权记录
oauth = await db.execute(
select(UserOAuth).where(
UserOAuth.id == oauth_id,
)
)
oauth = oauth.scalar_one_or_none()
if not oauth:
return {
"success": False,
"error": "授权记录不存在"
}
account_role = oauth.account_role
if resource_type == "image":
if resource.file_size_bytes > 5 * 1024 * 1024:
return {
@@ -292,17 +306,21 @@ async def _upload_to_juliang(
image_signature = hashlib.md5(file_content).hexdigest()
data = {
"advertiser_id": advertiser_id,
"upload_type": "UPLOAD_BY_FILE",
"image_signature": image_signature,
"filename": filename,
}
files = {
"image_file": (filename, file_content, "image/png"),
}
response = await douyin_api.upload_image_material(oauth_id, data, files)
#如果account_role授权角色包含:LOCAL,那么就是本地推接口,其他是广告千川接口
if "LOCAL" in account_role:
data["local_account_id"] = advertiser_id
response = await douyin_api.upload_local_image_material(oauth_id, data, files)
else:
data["advertiser_id"] = advertiser_id
response = await douyin_api.upload_image_material(oauth_id, data, files)
if response["code"] != 0:
return {
@@ -375,17 +393,20 @@ async def _upload_to_juliang(
video_signature = hashlib.md5(file_content).hexdigest()
data = {
"advertiser_id": advertiser_id,
"upload_type": "UPLOAD_BY_FILE",
"video_signature": video_signature,
"filename": filename,
}
files = {
"video_file": (filename, file_content, "video/mp4"),
}
response = await douyin_api.upload_video_material(oauth_id, data, files)
if "LOCAL" in account_role:
data["local_account_id"] = advertiser_id
response = await douyin_api.upload_local_video_material(oauth_id, data, files)
else:
data["advertiser_id"] = advertiser_id
response = await douyin_api.upload_video_material(oauth_id, data, files)
if response["code"] != 0:
return {