Access-Control-Allow-Origin responses in Standard OAuth2.0 App

回答済み
新規投稿

コメント

1件のコメント

  • MangoCats

    Working now... needed to wrap the file data in a Blob (the filename passed to the Blob creator is ignored):

     

    $scope.sendFile = function sendFile()
    { const foo = new FormData();
    foo.append( 'attributes', '{"name":"testFileName","parent":{"id":"0"}}' );
    foo.append( 'file', new Blob( ["mary had\na little lamb"],{type:"text/plain"}) );
    var req =
    { method: 'POST',
    url: 'https://upload.box.com/api/2.0/files/content',
    headers: { 'Authorization': 'Bearer $$boxAccessToken$$',
    'Content-Type': undefined
    },
    data: foo
    };
    $http( req ).then( sendFile2, netFailHandler );
    }

     

    The working request body looks like this, seems like having the Content-Type specified on the file part of the body is what was missing:

     

    -----------------------------420sep
    Content-Disposition: form-data; name="attributes"

    {"name":"testFileName","parent":{"id":"0"}}
    -----------------------------420sep
    Content-Disposition: form-data; name="file"; filename="blob"
    Content-Type: text/plain

    mary had
    a little lamb
    -----------------------------420sep--

     

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

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