本文整理汇总了TypeScript中@jupyterlab/filebrowser.FileBrowserModel.upload方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FileBrowserModel.upload方法的具体用法?TypeScript FileBrowserModel.upload怎么用?TypeScript FileBrowserModel.upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@jupyterlab/filebrowser.FileBrowserModel
的用法示例。
在下文中一共展示了FileBrowserModel.upload方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should overwrite', () => {
let fname = UUID.uuid4() + '.html';
let file = new File(['<p>Hello world!</p>'], fname, {
type: 'text/html'
});
return model
.upload(file)
.then(contents => {
expect(contents.name).to.be(fname);
acceptDialog();
return model.upload(file);
})
.then(contents => {
expect(contents.name).to.be(fname);
});
});
示例2: it
it(`should produce progress as a large file uploads`, async () => {
const fname = uuid() + '.txt';
const file = new File([new ArrayBuffer(2 * CHUNK_SIZE)], fname);
const {cleanup, values: [start, first, second, finished]} = signalToPromises(model.uploadChanged, 4);
model.upload(file);
expect(iteratorToList(model.uploads())).to.eql([]);
expect(await start).to.eql([model, {name: 'start', oldValue: null, newValue: {path: fname, progress: 0}}]);
expect(iteratorToList(model.uploads())).to.eql([{path: fname, progress: 0}]);
expect(await first).to.eql([model, {name: 'update', oldValue: {path: fname, progress: 0}, newValue: {path: fname, progress: 0}}]);
expect(iteratorToList(model.uploads())).to.eql([{path: fname, progress: 0}]);
expect(await second).to.eql([model, {name: 'update', oldValue: {path: fname, progress: 0}, newValue: {path: fname, progress: 1 / 2}}]);
expect(iteratorToList(model.uploads())).to.eql([{path: fname, progress: 1 / 2}]);
expect(await finished).to.eql([model, {name: 'finish', oldValue: {path: fname, progress: 1 / 2}, newValue: null}]);
expect(iteratorToList(model.uploads())).to.eql([]);
cleanup();
});
示例3: expect
model.upload(file).then(contents => {
expect(contents.name).to.be('hello2.html');
return model.upload(file);
}).catch(err => {
示例4: expect
.then(contents => {
expect(contents.name).to.be(fname);
dismissDialog();
return model.upload(file);
})