Trying to upload file resulting with Empty response or curl: (26) couldn't open file

新規投稿

コメント

4件のコメント

  • Prabakar8177

    Ok, I had another update on the same query:

     

    curl https://upload.box.com/api/2.0/files/content \
    -H "Authorization: Bearer sfsfsdfsdfhghjhgjdsfsfsmUpQQN2ia" -X POST \
    -F attributes='{"name":"test.txt", "parent":{"id":"123123123"}}' \
    -F file=@test.txt

     

    Response in Terminal on Mac:

     

    {"type":"error","status":409,"code":"item_name_in_use","context_info":{"conflicts":{"type":"file","id":"60***phone number removed for privacy***","file_version":{"type":"file_version","id":"638521169833","sha1":"xxxxxxxyyyyyyzzzzzf763cce44574a5b5ab03"},"sequence_id":"0","etag":"0","sha1":"c0b137fe2d792459f26ff763cce44574a5b5ab03","name":"test.txt"}},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Item with the same name already exists","request_id":"kzynrtgb608vl1dw"}

     

    But, there is NO file like that in box folder.

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

    Hi ,

     

    Typically this is due to the file being uploaded to another user / account than the one you're looking at. For instance, if you're using a JWT based application and auth as the enterprise, then the file would be uploaded to the service account, not your user account. If that's your application type then you can go to the content section of your admin console, then under users there should be a user with the same name as your app. Clicking on that will show whether the file went up there or not. 

     

    Basically I would recommend ensuring that your access token is scoped for the user that you're intending to upload to. You can also user the get current user endpoint call to verify the scope of the token.

     

    - Jon

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

    Yes, I am trying to upload to a service account created by my senior. I am testing this in Terminal as command on MacBook.

     

    1. Do we need to use "parent" or "file" ID here? Because, looks like "file" id works fine.

     

    curl https://upload.box.com/api/2.0/files/content \
    -H "Authorization: Bearer jshdkjasdjkasdh832183" -X POST \
    -F attributes='{"name":"test.txt", "parent":{"id":"111111111"}}' \
    -F file=@test.txt

     

    2. Do we need to use full path URL or not?

    -F attributes='{"name":"/Users/plo2771⁩/test.txt", "parent":{"id":"111111111"}}'

    or

    -F attributes='{"name":"test.txt", "parent":{"id":"111111111"}}' \

     

    if we use full path, it gives error "couldn't open file" , but the file is in read/write mode. I am using MacBook.

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

    Hi ,

     

    For #1, parent ID is required, and that will be the ID of the folder that the file should be uploaded into.

     

    For #2, no, you don't need to use the full path. That name field is the name / extension that the file should be given when it is stored in Box, which may be different than the actual filename on the system you're uploading from.

     

    - Jon

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

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