fix: media upload to have applicationName as User-Agent#2227
fix: media upload to have applicationName as User-Agent#2227suztomo merged 4 commits intogoogleapis:mainfrom
Conversation
|
LGTM -- Changes make sense. I do that the AbstractGoogleClient. I think this is searchable on CloudRAD, but is hidden away in the Builder: https://cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.AbstractGoogleClient.Builder#com_google_api_client_googleapis_services_AbstractGoogleClient_Builder_setApplicationName_java_lang_String_
Do you think it would make sense to have this documented a bit more visible? |
Yeah, I think it's fine as it is. Personally, I would have assumed setting the user-agent would be something like I do see there are guides here: https://googleapis.github.io/google-api-java-client/media-upload.html. Maybe a quick blurb/ section/ example on this page about how applicationName is the user-agent that is passed in the headers -- or if you think it's already clear enough I'm fine with as well. |
| String applicationName = abstractGoogleClient.getApplicationName(); | ||
| HttpRequestInitializer requestInitializer = | ||
| mediaUploadRequestUserAgentInitializer(applicationName, requestFactory.getInitializer()); | ||
| this.uploader = |
|
@BenWhitehead Would you review this fix? The pull request description has how I confirmed it with regard to the internal bug b/252963877. |


Fixes #2222
How I confirmed the fix:
I locally installed this branch via
mvn installand specified the SNAPSHOT version of the BOM:I ran @BenWhitehead 's reproducer (with my small modification):
Note that userAgent is used in only
setApplicationName(userAgent).I placed src/main/resources/logging.properties so that it prints debug (FINE-level) log:
This is specified via
-Djava.util.logging.config.file=src/main/resources/logging.propertiesargument in IntelliJ.It printed out the expected User-Agent when uploading the data: