I am currently using `BatchJobService` to process the upload of `image_ad`. I encountered a problem when I `build_ad_group_ad_operation`. When I want to upload the image to Google and use Google's image connection, I found that I can't get the image link in Google: `https://tpc.googlesyndication.com/simgad/xxxxxxxxxxxxxxxxxxx`
```python def build_ad_group_ad_operation(client, customer_id, ad_group_resource_name, ad_type, display_campaign_ad_group_ad_id): ad_group_ad_operation = client.get_type("AdGroupAdOperation") ad_group_ad = ad_group_ad_operation.create ad_group_ad.status = client.enums.AdGroupAdStatusEnum.ENABLED ad_group_ad.ad_group = ad_group_resource_name base_final_url = google_ads_account_info[str(customer_id)]['base_final_url'] display_url = google_ads_account_info[str(customer_id)]['display_url'] if ad_type == ads_models.DisplayCampaignPublishInfoAdTypeChoices.IMAGE_AD: display_campaign_ad_group_ad_obj = ads_models.DisplayCampaignAdGroupAdHistory.objects.filter( id=display_campaign_ad_group_ad_id ).first() material_obj = display_campaign_ad_group_ad_obj.creative.materials.first() origin_material_obj = material_obj.origin_material mime_type = origin_material_obj.mime_type pixel_width = int(origin_material_obj.resolution_width) pixel_height = int(origin_material_obj.resolution_height) image_url = origin_material_obj.file_url image_name = material_obj.name ad_group_ad.ad.final_urls.append(f'{base_final_url}/shares') ad_group_ad.ad.display_url = display_url ad_group_ad.ad.name = display_campaign_ad_group_ad_obj.creative.name ad_group_ad.ad.image_ad.pixel_width = pixel_width ad_group_ad.ad.image_ad.pixel_height = pixel_height # TODO: 方案一: 先把图片上传至google, 再使用google的图片链接, 但是暂时不知如何合并至batch中 asset_resource_name, image_asset_image_url = create_ad_image_asset( client, customer_id, image_url, pixel_width, pixel_height, image_name ) ad_group_ad.ad.image_ad.image_url = image_asset_image_url # TODO: 方案二: 使用 image_asset 信息, 可以直接放到batch中, 但是不知道最终效果使用的是什么图片 待验证 # asset_resource_name, image_asset_image_url = create_ad_image_asset( # client, customer_id, image_url, pixel_width, pixel_height, image_name # ) # ad_group_ad.ad.image_ad.image_asset.asset = asset_resource_name if mime_type == 'image/jpeg': ad_group_ad.ad.image_ad.mime_type = client.enums.MimeTypeEnum.IMAGE_JPEG elif mime_type == 'image/png': ad_group_ad.ad.image_ad.mime_type = client.enums.MimeTypeEnum.IMAGE_PNG elif mime_type == 'image/gif': ad_group_ad.ad.image_ad.mime_type = client.enums.MimeTypeEnum.IMAGE_GIF else: ad_group_ad.ad.image_ad.mime_type = client.enums.MimeTypeEnum.UNSPECIFIED elif ad_type == ads_models.DisplayCampaignPublishInfoAdTypeChoices.IMAGE_AD_HTML5: ad_type_ = 'h5' elif ad_type == ads_models.DisplayCampaignPublishInfoAdTypeChoices.RESPONSIVE_DISPLAY_AD: ad_type_ = 'res' else: return [] return ad_group_ad_operation ``` ```python def create_ad_image_asset(client, customer_id, image_url, width_pixels, height_pixels, image_name): response = requests.get(image_url) image_content = response.content mime_type = response.headers['Content-Type'] asset_service = client.get_service("AssetService") asset_operation = client.get_type("AssetOperation") asset = asset_operation.create asset.type_ = client.enums.AssetTypeEnum.IMAGE asset.image_asset.data = image_content asset.image_asset.file_size = len(image_content) if mime_type == 'image/jpeg': asset.image_asset.mime_type = client.enums.MimeTypeEnum.IMAGE_JPEG elif mime_type == 'image/png': asset.image_asset.mime_type = client.enums.MimeTypeEnum.IMAGE_PNG elif mime_type == 'image/gif': asset.image_asset.mime_type = client.enums.MimeTypeEnum.IMAGE_GIF else: asset.image_asset.mime_type = client.enums.MimeTypeEnum.UNSPECIFIED asset.image_asset.full_size.width_pixels = width_pixels asset.image_asset.full_size.height_pixels = height_pixels asset.name = image_name mutate_asset_response = asset_service.mutate_assets( customer_id=str(customer_id), operations=[asset_operation] ) print(f'mutate_asset_response: {mutate_asset_response}') asset_resource_name = mutate_asset_response.results[0].resource_name image_asset_image_url = mutate_asset_response.results[0].asset.image_asset.full_size.url return asset_resource_name, image_asset_image_url ``` The function `create_ad_image_asset` can only return `asset_resource_name`. ```python console mutate_asset_response: results { resource_name: "customers/11111111/assets/225688809944" } ``` What I need is `asset.image_asset.full_size.url` and apply it to `ad_group_ad.ad.image_ad.image_url`. How should I implement this function? In addition, inserting a synchronization task into BatchJobService is a very irrational approach, but I don't know how to effectively upload images in batchjob and get `asset.image_asset.full_size.url`. Can it use a temporary id? If there is any good solution, please tell me. Thank you. -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "Google Ads API and AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/adwords-api/0f077108-1954-45e6-85e5-06816a856522n%40googlegroups.com.