我正在尝试实施https://ionicframework.com/docs/native/file-transfer/
因此我需要安装https://ionicframework.com/docs/native/file/
当我在我的服务中使用“文件”时,我收到错误:
无法解析文件的所有参数:(?,?,?,?,?)。
我知道问号可能类似于循环引用,我从未在其他地方使用过我的服务,也没有使用过“文件”。
import {Injectable} from '@angular/core';
import {File} from "@ionic-native/file";
import { FileTransfer, FileTransferObject } from '@ionic-native/file-transfer';
@Injectable()
export class ImageService {
constructor(private file: File, private transfer: FileTransfer) {
}
public getImagesOfSchedule() {
const fileTransfer: FileTransferObject = this.transfer.create();
const url = 'http://techbooster.be/wp-content/uploads/2017/11/logo-long-white.png';
fileTransfer.download(url, this.file.dataDirectory + 'file.pdf').then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
// handle error
});
}
}
app.module.ts
providers: [
StatusBar,
AuthenticationService,
ScheduleService,
ToastService,
StorageService,
FacebookService,
GoogleService,
ImageService,
Facebook,
GooglePlus,
PushService,
File, <----------------
FileTransfer, <--------------
Push,
ScreenOrientation,
{
provide: HttpService,
useFactory: HttpFactory,
deps: [XHRBackend, RequestOptions]
},
{
provide: HttpNoAuthService,
useFactory: HttpFactory,
deps: [XHRBackend, RequestOptions]
},
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
答案 0 :(得分:6)
好的,我发现在app.module.ts中自动导入的File类不是:
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
active_link_to was resolved to 1.0.3, which depends on
actionpack
active_model_serializers was resolved to 0.10.2, which depends on
actionpack (< 6, >= 4.1)
inherited_resources was resolved to 1.6.0, which depends on
actionpack (< 5, >= 3.2)
inherited_resources was resolved to 1.6.0, which depends on
actionpack (< 5, >= 3.2)
kaminari was resolved to 0.17.0, which depends on
actionpack (>= 3.0.0)
rails (= 5.0.0) was resolved to 5.0.0, which depends on
actionpack (= 5.0.0)
rails (= 5.0.0) was resolved to 5.0.0, which depends on
actionpack (= 5.0.0)
rspec-rails (= 3.6.0) was resolved to 3.6.0, which depends on
actionpack (>= 3.0)
而是自动导入了一些标准的“lib.es6.d.ts”。
因此,请确保导入正确的“文件”类!