当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript file.File类代码示例

本文整理汇总了TypeScript中@ionic-native/file.File的典型用法代码示例。如果您正苦于以下问题:TypeScript File类的具体用法?TypeScript File怎么用?TypeScript File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了File类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: uploadPhoto

  async uploadPhoto(imageFileUri: any): Promise<void> {
    this.myPhoto = imageFileUri;

    this.error = null;
    this.loading = this.loadingCtrl.create({
      content: 'Uploading...'
    });

    await this.loading.present();

    const fileTransfer: FileTransferObject = this.transfer.create();

    const fileEntry = await this.file.resolveLocalFilesystemUrl(imageFileUri);

    const options: FileUploadOptions = {
      fileKey: 'file',
      fileName: fileEntry.name,
      headers: {}
    };

    try {
      const result = await fileTransfer.upload(imageFileUri, 'http://192.168.178.84:8080/upload', options);
      console.log(result.bytesSent);
      console.log(result.responseCode);
      this.showToast(true);
    }
    catch (e) {
      console.log(e);
      this.showToast(false);
    }
    finally {
      this.loading.dismiss();
    }
  }
开发者ID:ralscha,项目名称:attic,代码行数:34,代码来源:home.ts

示例2:

const existsFile = (path, filename) =>
	FILE.checkFile(path, filename).catch((e) => {
		if (e.code === 1) {
			return false
		}
		return Bluebird.reject(e)
	})
开发者ID:whispeer,项目名称:app,代码行数:7,代码来源:blobCache.ts

示例3: resolve

 return new Promise<void>((resolve, reject) => {
   this.file.removeFile(this.dir.nativeURL, k).then( () => {
     this.log.debug('File removed: ' + k);
     resolve();
   }).catch( (e) => {
     this.log.error(e);
     reject(e);
   });
 });
开发者ID:bitjson,项目名称:copay,代码行数:9,代码来源:file-storage.ts

示例4: getCacheDirectory

		return Bluebird.try(async () => {
			const cacheDir = await getCacheDirectory()
			const blobFile = idToFileName(blobID)
			const path = isAndroid() ? `${FILE.externalRootDirectory}Download/` : `${FILE.documentsDirectory}`
			const existsSource = await existsFile(cacheDir, blobFile)
			const existsDestination = await existsFile(path, filename)

			if (!existsSource) {
				throw new Error(`cannot copy blob, blob does not exist: ${filename}`)
			}

			if (existsDestination) {
				await FILE.removeFile(path, filename)
			}

			await FILE.copyFile(cacheDir, blobFile, path, filename)

			return `${path}${filename}`
		})
开发者ID:whispeer,项目名称:app,代码行数:19,代码来源:blobCache.ts

示例5: copyFile

  // http://ngcordova.com/docs/plugins/file/
  public copyFile(fullFilePath:string, destinationDirectory: string, newFileName? :string) : void {
    let fileName: string = fullFilePath.split('/').pop();
    let cachedImagePath: string = fullFilePath.substring(0, fullFilePath.lastIndexOf('/') + 1);
    let newName: string = newFileName ? newFileName: fileName;

    this.file.copyFile(cachedImagePath, fileName, destinationDirectory, newName).then((result: any) => {
      console.log('File: ' + fileName + ' copied to path: ' + destinationDirectory);
    }).catch(error => {
      console.log('Error when copy file: ' + fileName + ' to path: ' + destinationDirectory + ' - ' + error.message);
    });
  }
开发者ID:exodinn,项目名称:StarterKit,代码行数:12,代码来源:file-service.ts

示例6: writeFileFromBase64

 // here is the method is used to write a file in storage
 // https://www.c-sharpcorner.com/article/how-to-save-picture-to-specific-path-in-ionic-3-using-native-camera-plugin/
 public writeFileFromBase64(base64Data: any, filePath: string, fileName?: string): void {
   let contentType: any = this.getContentType(base64Data);
   let dataBlob: Blob = this.base64toBlob(base64Data.split(',')[1], contentType);
   // TODO dummy random name implementation
   let newFileName: string = fileName ? fileName : Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)+'.jpeg';
   this.file.writeFile(filePath, newFileName, dataBlob, contentType).then((success) => {
     console.log('File Writed Successfully to location: ' + filePath + newFileName);
   }).catch((err) => {
     console.log('Error Occured While Writing File: '+ filePath + newFileName, err.message);
   })
 }
开发者ID:exodinn,项目名称:StarterKit,代码行数:13,代码来源:file-service.ts

示例7: Error

		}).catch(error => {
			return FILE.createDir(basePath, BLOB_CACHE_DIR, true).then(dirEntry => {
				return desiredPath
			}).catch(error => {
				throw new Error('Could not create blob cache directory.')
			})
		})
开发者ID:whispeer,项目名称:app,代码行数:7,代码来源:blobCache.ts

示例8: Observable

 return new Observable(observer => {
   this.file.resolveDirectoryUrl(this.file.dataDirectory).then((directory: DirectoryEntry) => {
     this.file.getDirectory(directory, dirPath, {})
       .then((dir: DirectoryEntry) => observer.next(dir))
       .catch((error) => observer.error(error));
   });
 });
开发者ID:CIRDLES,项目名称:CHRONI,代码行数:7,代码来源:FileUtility.ts

示例9: abrir

 abrir(directorio){
   console.log(directorio.fullPath)
   this.file.listDir(this.file.externalRootDirectory, directorio.fullPath.substring(1, directorio.fullPath.length)).then(
     (list) => {
       console.log(list);
       this.directorios = list;
     }
   ).catch(e => console.log(e));
 }
开发者ID:dguerrerom01,项目名称:exploradorArchivos,代码行数:9,代码来源:home.ts

示例10: retroceder

  retroceder(){
    console.log(this.file.externalRootDirectory)
    this.file.listDir(this.file.externalRootDirectory, '').then(
      (list) => {
        console.log(list);
        this.directorios = list;
      }
    ).catch(e => console.log(e));

  }
开发者ID:dguerrerom01,项目名称:exploradorArchivos,代码行数:10,代码来源:home.ts


注:本文中的@ionic-native/file.File类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。