新しいBoxサポートサイトへようこそ。 変更点の詳細はこちらをご確認ください .

コメント

3件のコメント

  • Rui Barbosa

    Hi Logan,

    Directly from the Box API, I don't think so.

    You can, however, download the current and previous versions from box and then do a "local" comparison using some other "diff" tool.

    Let us know if this helps.

    Best regards

    1
    コメントアクション パーマリンク
  • Logan Ickert

    That does help, thanks for the insights.

    I noticed in the SDK docs that you have to pass a version number in order to get a previous version of a file. In the box interface it says that our account only stores the 50 most recent versions of the file, with the current version being v51 and the previous version being v50. If I set the version to '50' will it always get the previous version?

    0
    コメントアクション パーマリンク
  • Rui Barbosa

    Hi Logan,

    I wonder what SDK are you using.

    So looking at the API for file versions, we need to pass the file id, and if you want to get a specific version you'll need the version id.

    This version id is not predictable.

    For example, using postman on a file with 3 versions (the current and 2 previous):

    In the box app (notice the file id in the URL)

    Now in postman, querying the versions for that file:

    So notice how the version id is not predictable, i.e., 1, 2, etc, and also the current version is not listed on the versions query result.

    The first one of this list is always the most recent version, other than the current version.

    So for your use case, where the current version is 51, you could query the file to get the current version (v51), and then query the file versions, and get the first one of this list to get the previous version of the file (v50)

    Looking at the Python SDK for example:

    file_id = '11111'
    
    file_versions = client.file(file_id).get_previous_versions()
    for version in file_versions:
        print(f'File version {version.id} was created at {version.created_at}')

    Most of the download methods of a file support an optional parameter for the version id.

    For example the download_to method of the File object:

    def download_to(
    self,
    writeable_stream: IO[bytes],
    file_version: Optional['FileVersion'] = None,
    byte_range: Tuple[int, int] = None
    ) -> None:

    or the get download_url:

    def get_download_url(self, file_version: Optional['FileVersion'] = None) -> str:
    Let us know your thoughts.
    Best regards
    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。