Hey there, I’m building my first Ionic app and I’m using a CSV file as the data source for a table.
How can I include this file on a release build?
Include the file in your assets
folder, for example:
├── /assets
└── /data
├── data-file.csv
Hey, thanks in advance!
It seems that it is included, judging by the increase in APK’s size but I can’t seem to find my file
I’ve tried using the File plugin on “applicationDirectory”
Things in assets
are not files from the POV of the device. They are baked into your app binary. HTTP is the simplest way to retrieve them.
Try something like:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { Venue } from '@core/models';
@Injectable()
export class MockVenuesService {
private readonly URL = 'assets/data/venues.json';
constructor(protected httpClient: HttpClient) {}
public list(): Observable<Venue[]> {
return this.httpClient.get<Venue[]>(this.URL);
}
}
See:
hey sorry for the huge delay for an answer but I was in a rush
y’know, undergraduate life
but it worked, using Http to get the file
thank you very much!