@prisma/client#Download TypeScript Examples
The following examples show how to use
@prisma/client#Download.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: middleware.ts From frames with Mozilla Public License 2.0 | 5 votes |
/**
* @desc gets a file's location from the request
* @param location - file location
*/
public async getFileAndAndLocation(location: string) {
let res: {location: string, download: boolean, name: string} = {
location: '',
download: false,
name: ''
};
const { data, error } = await this.supabase
.from<(View & {video: Video})>('View')
.select('*,video:Video(*)')
.eq('auth', location)
.single();
if (!error && data) {
const { video } = data;
res = {
location: video.location,
download: false,
name: ''
}
} else {
const { data, error } = await this.supabase
.from<(Download & {view: (View & {episode: Episode, video: (Video & {media: Media})})})>('Download')
.select('*,view:View(*,episode:Episode(*),video:Video(*,media:Media!Video_mediaId_fkey(*)))')
.eq('location', location)
.single();
if (!error && data) {
if (data.view.episode) {
const { episode, video } = data.view;
const { media } = video;
const episodeInfo = await this.getEpisode(media.tmdbId, episode.seasonId, episode.episode);
res = {
location: video.location,
download: true,
name: media.name + (/^Episode \d+/i.test(episodeInfo?.name || 'Episode 0') ? ` Season ${episode.seasonId} - Episode ${episode.episode}` : ` S${episode.seasonId} - E${episode.episode}: ${episodeInfo?.name}`)
}
} else {
const { video } = data.view;
res = {
location: video.location,
download: true,
name: video.media.name
}
}
}
}
return res;
}