1

파일을 드라이브로 업데이트 할 때 충돌을 감지하고 싶습니다. 이를 위해 it seems I have to set the If-Match header.드라이브 요청에 HTTP 헤더를 설정하십시오.

현재,이 한 줄에 Google 드라이브에 문서를 업데이트 :

mDriveFile = mService.files().update(mDriveFile.getId(), mDriveFile, byteContent).execute(); 

요청에 If-Match 헤더를 추가하는 가장 간단한 방법은 무엇입니까? Example in Files: update documentation은 HTTP 헤더를 설정하는 방법을 알려주지 않습니다.

답변

0

당신은 Update 개체에서 헤더를 얻을 자신을 추가하고 HTTP 요청을 실행하기 전에 그들을 다시 넣을 수 있습니다 :

final Update update = mService.files().update(mDriveFile.getId(), mDriveFile, byteContent); 
final HttpHeaders headers = update.getRequestHeaders(); 
headers.setIfMatch("TheETagStoredFromDownload"); 
update.setRequestHeaders(headers); 
mDriveFile = update.execute();