PHP Box.com上传文件GuzzleHttp 6

时间:2018-03-14 09:59:35

标签: php curl guzzle box

我需要向box.com请求使用GuzzleHttp 6上传文件。

cURL中的请求是:

 curl https://upload.box.com/api/2.0/files/content 
   -H "Authorization: Bearer ACCESS_TOKEN" 
   -X POST 
   -F attributes='{"name":"tigers.jpeg", "parent":{"id":"11446498"}}
   -F file=@myfile.jpg

请参阅https://developer.box.com/reference#upload-a-file以供参考。

同样在我的情况下,我没有文件,只有文件内容。

1 个答案:

答案 0 :(得分:2)

在过去的两天里,我一直在寻找答案。 和宾果....在问了一个问题后1分钟我设法写了一些有用的东西:

Ext.application({
    name: 'Fiddle',

    launch: function () {
        Ext.create({
            xtype: 'panel',
            fullscreen: true,
            layout: {
                type: 'vbox',
                align: 'stretch',
                pack: 'start'
            },
            items: [{
                xtype: 'panel',
                layout: {
                    type: 'hbox',
                    align: 'stretch',
                    pack: 'start'
                },
                items: [{
                    xtype: 'radiofield',
                    flex: 3,
                    label: 'afglngfsdlgkdslfkjsdlfkjdslkfjdslfkjsdlfkjsdlkfjsdlkfjsdlkfjdslkfjsdlkfjsdlkfjdslkfjldskfjsldkfjlsdkfjlsdkfjlsdkfjlsdkfjlkdsjflsdkjflsdkjflsdkjflsdkjflsdkjfklslfkdfjsldfk',
                    labelAlign: 'right',
                    labelWidth: 'auto',
                    name: 'color',
                    value: 'red',
                    checked: true
                }, {
                    xtype: 'textfield',
                    placeHolder: 'example',
                    flex: 1,
                    margin: '0 0 0 10'
                }, {
                    xtype: 'radiofield',
                    flex: 1,
                    label: 'The word-break CSS property specifies whether or not the browser should insert line breaks wherever the text would otherwise overflow its content box.',
                    labelAlign: 'right',
                    labelWrap: true,
                    labelWidth: 'auto',
                    name: 'color',
                    value: 'red'
                }]
            }]
        });
    }
});