2014-05-16 2 views
0

developer road map에는 2013 년 12 월부터 "잠금/잠금 해제 - V2 API에 파일 잠금 및 잠금 해제에 대한 지원이 추가되었습니다."라는 메모가 있습니다.Box V2 API - 잠금/잠금 해제 위치는 어디입니까?

저는 모두 V2 API (C#의 경우)를 통해 어디서나 찾을 수 없었습니다. BoxFilesManager 클래스에서 뭔가를 찾거나 또는 UpdateInformationAsyncBoxFileRequest 클래스 내에서 뭔가를 찾을 것으로 예상됩니다.

파일 잠금/잠금 해제 방법이 있습니까?

답변

0

큰 질문입니다. 파일에는 잠금 장치가없는 경우보기 위해 파일의 현재 잠금 상태가

GET https://api.box.com/2.0/files/7435988481/?fields=lock 

을, 당신이 다시 뭔가를 얻을 것이다 : 당신이 잠 그려면

{ 
    "type": "file", 
    "id": "7435988481", 
    "etag": "0", 
    "lock": null 
} 

파일을 만들려면 /fs/endpoint에서 PUT (업데이트)을 수행하여 잠금 유형을 알려주는 본문 및 릴리스시기를 알려줘야합니다. 이처럼 : 당신은 당신의 잠금 장치를 확인하는 응답을 얻을 것이다

PUT https://api.box.com/2.0/files/7435988481/?fields=lock 

{"lock": { 
"expires_at" : "2014-05-29T19:03:04-07:00", 
    "is_download_prevented": true 
} 
} 

가 작성되었습니다

{ 
    "type": "file", 
    "id": "7435988481", 
    "etag": "1", 
    "lock": { 
     "type": "lock", 
     "id": "14516545", 
     "created_by": { 
      "type": "user", 
      "id": "13130406", 
      "name": "Peter Rexer gmail", 
      "login": "[email protected]" 
     }, 
     "created_at": "2014-05-29T18:03:04-07:00", 
     "expires_at": "2014-05-29T19:03:04-07:00", 
     "is_download_prevented": true 
    } 
} 
+0

. C# API 호출도 있습니까? – kberson

+0

어 ... 세계의 C# 구루 사? 누구든지 SDK에 추가하고 싶습니까? 아마도 기능 요청을해야합니다 .. https://github.com/box/box-windows-sdk-v2 또는 https://github.com/jhoerr/box-csharp-sdk-v2 – Peter

+0

JHoerr is out, stopped 상자가 나왔을 때 그 도서관을 유지하십시오. – kberson

0

잠금이/아직 잠금 해제가 있기 때문에, 나는 기존의 관리자를 기반으로 잠금 관리자를 생성 :

class BoxCloudLockManager : BoxResourceManager 
{ 
    #region Lock/Unlock Classes 
    [DataContract] 
    internal class BoxLockRequestInfo 
    { 
     [DataMember(Name = "status")] 
     public string Status { get; set; } 
     //[DataMember(Name = "expires_at")] 
     //public string ExpiresAt { get; set; } 
     [DataMember(Name = "is_download_prevented")] 
     public bool IsDownloadPrevented { get; set; } 
    } 

    [DataContract] 
    internal class BoxLockRequest 
    { 
     [DataMember(Name = "lock")] 
     public BoxLockRequestInfo Lock { get; set; } 
    } 
    #endregion 

    const string LockFileString = "{0}/?fields=lock"; 

    public BoxCloudLockManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth) 
     : base(config, service, converter, auth) 
    { 
    } 

    public async Task<BoxLockInfo> LockAsync(string documentId,bool isDownloadPrevented = true) 
    { 
     var lockRequest = new BoxLockRequest { Lock = new BoxLockRequestInfo { Status = "lock", IsDownloadPrevented = isDownloadPrevented } }; 

     BoxRequest request = new BoxRequest(_config.FilesEndpointUri, string.Format(LockFileString, documentId)) 
      .Method(RequestMethod.Put) 
      .Payload(_converter.Serialize(lockRequest)); 

     IBoxResponse<BoxLockInfo> response = await ToResponseAsync<BoxLockInfo>(request).ConfigureAwait(false); 

     return response.ResponseObject; 
    } 

    public async Task<BoxLockInfo> UnlockAsync(string documentId) 
    { 
     BoxRequest request = new BoxRequest(_config.FilesEndpointUri, string.Format(LockFileString, documentId)) 
      .Method(RequestMethod.Put) 
      .Payload("{\"lock\":null}"); 

     IBoxResponse<BoxLockInfo> response = await ToResponseAsync<BoxLockInfo>(request).ConfigureAwait(false); 

     return response.ResponseObject; 
    } 

    public async Task<BoxLockInfo> GetLockInfoAsync(string documentId) 
    { 
     BoxRequest request = new BoxRequest(_config.FilesEndpointUri, string.Format(LockFileString, documentId)) 
      .Method(RequestMethod.Get); 

     IBoxResponse<BoxLockInfo> response = await ToResponseAsync<BoxLockInfo>(request).ConfigureAwait(false); 

     return response.ResponseObject; 
    } 
} 

BoxClient의 클래스를 파생시키고 LockManager를 추가하고 생성자 내에서 인스턴스를 생성했습니다. 여기

은 잠금 정보입니다 :

GET/PUT을 사용하여 상태를 확인하는 방법은
[DataContract] 
public class BoxLockedBy 
{ 
    [DataMember(Name = "type")] 
    public string Type { get; set; } 
    [DataMember(Name = "id")] 
    public string Id { get; set; } 
    [DataMember(Name = "name")] 
    public string Name { get; set; } 
    [DataMember(Name = "login")] 
    public string Login { get; set; } 
} 

[DataContract] 
public class BoxLockDetails 
{ 
    [DataMember(Name = "type")] 
    public string Type { get; set; } 
    [DataMember(Name = "id")] 
    public string Id { get; set; } 
    [DataMember(Name = "created_by")] 
    public BoxLockedBy CreatedBy { get; set; } 
    [DataMember(Name = "created_at")] 
    public string CreatedAt { get; set; } 
    [DataMember(Name = "expires_at")] 
    public string ExpiresAt { get; set; } 
    [DataMember(Name = "is_download_prevented")] 
    public bool IsDownloadPrevented { get; set; } 
} 

[DataContract] 
public class BoxLockInfo 
{ 
    [DataMember(Name = "type")] 
    public string Type { get; set; } 
    [DataMember(Name = "id")] 
    public string Id { get; set; } 
    [DataMember(Name = "etag")] 
    public string Etag { get; set; } 
    [DataMember(Name = "lock")] 
    public BoxLockDetails LockDetails { get; set; } 
} 
관련 문제