我正在尝试在AWS s3上传图像,因为我正在使用@ ionic-native / file-transfer但是当我尝试添加FileUploadOptions时,我会收到错误。 FileTransfer和FileTransferObject不会发生错误。我需要用于AWS s3的FileUploadOptions.params
。
注意:我查看了node_modules / @ ionic-native / file-transfer,注释了一些FileUploadOptions代码。这是一个问题吗?有谁知道任何其他稳定的文件传输版本。我现在不在乎
我已经使用这些命令安装了脚本
$ ionic cordova plugin add cordova-plugin-file-transfer
$ npm install --save @ionic-native/file-transfer
比我更新了我的app.module.ts:
import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer';
在app.module.ts的提供者数组中:
providers: [
StatusBar,
FileUploadOptions,
FileTransfer,
FileTransferObject,
File,
Camera,
SplashScreen,
{
provide: ErrorHandler,
useClass: IonicErrorHandler
},
{
provide: AuthHttp,
useFactory: getAuthHttp,
deps: [Http]
},
DataServiceProvider,
LocationServiceProvider,
Geolocation,
JwtHelper,
AuthServiceProvider
]
当我在我的提供者数组中添加FileUploadOptions时,我收到此错误:
Typescript错误'FileUploadOptions'仅引用类型,但在此处用作值。 C:/xampp/htdocs/ionic/tellworld-mobile/src/app/app.module.ts StatusBar,FileUploadOptions,FileTransfer,
的package.json:
"dependencies": {
"@angular/common": "4.1.3",
"@angular/compiler": "4.1.3",
"@angular/compiler-cli": "4.1.3",
"@angular/core": "4.1.3",
"@angular/forms": "4.1.3",
"@angular/http": "4.1.3",
"@angular/platform-browser": "4.1.3",
"@angular/platform-browser-dynamic": "4.1.3",
"@ionic-native/camera": "^4.2.1",
"@ionic-native/core": "3.12.1",
"@ionic-native/file": "^4.2.1",
"@ionic-native/file-transfer": "^4.2.1",
"@ionic-native/geolocation": "^4.1.0",
"@ionic-native/splash-screen": "3.12.1",
"@ionic-native/status-bar": "3.12.1",
"@ionic/storage": "^2.0.1",
"@ngui/map": "^0.18.4",
"@types/googlemaps": "^3.26.20",
"angular2-jwt": "^0.2.3",
"cordova-ios": "^4.4.0",
"cordova-plugin-camera": "^2.4.1",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-file": "^4.3.3",
"cordova-plugin-file-transfer": "1.6.3",
"cordova-plugin-geolocation": "^2.4.3",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"cordova-sqlite-storage": "^2.0.4",
"ionic-angular": "3.6.0",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"moment": "^2.18.1",
"ngmap": "^1.18.4",
"rxjs": "5.4.0",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.12"
},
"devDependencies": {
"@ionic/app-scripts": "2.1.3",
"ionic": "3.9.2",
"typescript": "2.3.4"
},
你只需要在FileTransfer
数组中包含providers
:
providers: [
StatusBar,
// FileUploadOptions,
// FileTransferObject,
FileTransfer, // <--- This one!
File,
Camera,
SplashScreen,
{
provide: ErrorHandler,
useClass: IonicErrorHandler
},
{
provide: AuthHttp,
useFactory: getAuthHttp,
deps: [Http]
},
DataServiceProvider,
LocationServiceProvider,
Geolocation,
JwtHelper,
AuthServiceProvider
]
FileUploadOptions
和FileTransferObject
不是提供者,而只是在与插件交互时使用的类/接口。