本文整理匯總了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);
})