How to upload a file a folder shared by other

回答済み
新規投稿

コメント

2件のコメント

  • Jason

    Hey  , I think you might be running into an odd part of the as-user design, where you can't actually take actions on content external to your enterprise when you impersonate a managed user with "as-user". This is the same reason why you only see "External folder" in your admin console screenshot. 

     

    In terms of Box's product offerings, we have two ways for apps to impersonate users - one is as-user, which is designed to reflect one user (one access token) impersonating another user. The second way is generating a token for the user directly, which a flow specific to JWT auth. This is the flow you want, and you can do this in python with this excerpt:

    https://github.com/box/box-python-sdk/blob/master/docs/usage/authentication.md#server-auth-with-jwt

     

    You'll know you've done it right when you're able to return information about the external folders via the API.

     

    Hope that helps,

    Jason

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

    Hi Jason,

    I actually passed through document several times but cant get the idea. Now seem OK will few lines of code.

     

    auth = JWTAuth.from_settings_file(r'path-to-config-json')
    client = Client(auth)
    auth.authenticate_user('USER-ID')
    user_client = Client(auth)
    file_path = r'PATH-TO-UPLOAD-FILE'
    box_file = user_client.folder('ROOT-FOLDER-ID').upload(file_path)


    Thank you very much.

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

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