-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/modify private image retrieval (#740)
* feat: add util method to format media info * fix: use new method to retrieve media info * chore: remove unused imports * chore: modify arguments * Fix: don't export interface * fix: separate out media directory data retrieval from getMediaFileInfo * Fix: handle errors when retrieving images * Chore: move types to types/media * Refactor: move url retrieval into separate method * chore: update types and make isPrivate optional * Test/image retrieval tests (#741) * feat: add media fixtures * chore: remove private image tests and fix tests * feat: add tests for new media util method * Fix: screaming snake case * Fix: remove irrelevant test * chore: swap to jest-mock-axios * Update src/utils/__tests__/media-utils.spec.ts Co-authored-by: seaerchin <[email protected]> * Update src/utils/__tests__/media-utils.spec.ts Co-authored-by: seaerchin <[email protected]> * Chore: remove isMediaFileOutput * test: add new nested media test --------- Co-authored-by: seaerchin <[email protected]> --------- Co-authored-by: seaerchin <[email protected]>
- Loading branch information
1 parent
e883f73
commit c1363db
Showing
9 changed files
with
376 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { MediaType, MediaFile } from "@root/types" | ||
|
||
export const MEDIA_FILE_NAME = "test file" | ||
export const MEDIA_SITE_NAME = "site" | ||
export const MEDIA_DIRECTORY_NAME = "dir" | ||
export const MEDIA_SUBDIRECTORY_NAME = "sub dir" | ||
export const MEDIA_FILE_SHA = "sha" | ||
|
||
export const MEDIA_DIR: MediaFile = { | ||
name: "directory", | ||
type: "dir", | ||
sha: MEDIA_FILE_SHA, | ||
path: `${MEDIA_DIRECTORY_NAME}/directory`, | ||
} | ||
|
||
const BASE_MEDIA_FILE: MediaFile = { | ||
name: MEDIA_FILE_NAME, | ||
type: "file", | ||
sha: MEDIA_FILE_SHA, | ||
path: `${MEDIA_DIRECTORY_NAME}/${MEDIA_FILE_NAME}`, | ||
} | ||
|
||
export const NESTED_MEDIA_FILE: MediaFile = { | ||
...BASE_MEDIA_FILE, | ||
path: `${MEDIA_DIRECTORY_NAME}/${MEDIA_SUBDIRECTORY_NAME}/${MEDIA_FILE_NAME}`, | ||
} | ||
|
||
export const SVG_FILE = { | ||
...BASE_MEDIA_FILE, | ||
name: `${MEDIA_FILE_NAME}.svg`, | ||
path: `${MEDIA_DIRECTORY_NAME}/${MEDIA_FILE_NAME}.svg`, | ||
} | ||
|
||
const BASE_INPUT = { | ||
siteName: MEDIA_SITE_NAME, | ||
directoryName: MEDIA_DIRECTORY_NAME, | ||
} | ||
|
||
export const DIR_INPUT = { | ||
...BASE_INPUT, | ||
file: MEDIA_DIR, | ||
mediaType: "images" as MediaType, | ||
isPrivate: false, | ||
} | ||
|
||
export const IMAGE_FILE_PUBLIC_INPUT = { | ||
...BASE_INPUT, | ||
file: BASE_MEDIA_FILE, | ||
mediaType: "images" as MediaType, | ||
isPrivate: false, | ||
} | ||
|
||
export const NESTED_IMAGE_FILE_PUBLIC_INPUT = { | ||
...IMAGE_FILE_PUBLIC_INPUT, | ||
file: NESTED_MEDIA_FILE, | ||
directoryName: `${MEDIA_DIRECTORY_NAME}/${MEDIA_SUBDIRECTORY_NAME}`, | ||
} | ||
|
||
export const SVG_FILE_PUBLIC_INPUT = { | ||
...IMAGE_FILE_PUBLIC_INPUT, | ||
file: SVG_FILE, | ||
} | ||
|
||
export const IMAGE_FILE_PRIVATE_INPUT = { | ||
...IMAGE_FILE_PUBLIC_INPUT, | ||
isPrivate: true, | ||
} | ||
|
||
export const SVG_FILE_PRIVATE_INPUT = { | ||
...SVG_FILE_PUBLIC_INPUT, | ||
isPrivate: true, | ||
} | ||
|
||
export const PDF_FILE_PUBLIC_INPUT = { | ||
...IMAGE_FILE_PUBLIC_INPUT, | ||
mediaType: "files" as MediaType, | ||
} | ||
|
||
export const PDF_FILE_PRIVATE_INPUT = { | ||
...PDF_FILE_PUBLIC_INPUT, | ||
isPrivate: true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./axios" | ||
export * from "./error" | ||
export * from "./media" | ||
export * from "./request" | ||
export * from "./amplify" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export type ItemType = "dir" | "file" | ||
export type MediaType = "images" | "files" | ||
|
||
export interface MediaFile { | ||
name: string | ||
type: ItemType | ||
sha: string | ||
path: string | ||
} | ||
|
||
export interface MediaFileInput { | ||
file: MediaFile | ||
siteName: string | ||
directoryName: string | ||
mediaType: MediaType | ||
isPrivate?: boolean | ||
} | ||
|
||
export interface MediaFileOutput { | ||
name: string | ||
sha: string | ||
mediaUrl: string | ||
mediaPath: string | ||
type: ItemType | ||
} |
Oops, something went wrong.