Documentation ¶
Index ¶
- func GetPathFromBase64Hash(base64Hash types.Base64Hash, absBasePath config.Path) (string, error)
- func MoveFileWithHashCheck(tmpDir types.Path, mediaMetadata *types.MediaMetadata, absBasePath config.Path, ...) (types.Path, bool, error)
- func RemoveDir(dir types.Path, logger *log.Entry)
- func WriteTempFile(ctx context.Context, reqReader io.Reader, ...) (hash types.Base64Hash, size types.FileSizeBytes, path types.Path, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPathFromBase64Hash ¶
GetPathFromBase64Hash evaluates the path to a media file from its Base64Hash 3 subdirectories are created for more manageable browsing and use the remainder as the file name. For example, if Base64Hash is 'qwerty', the path will be 'q/w/erty/file'.
func MoveFileWithHashCheck ¶
func MoveFileWithHashCheck(tmpDir types.Path, mediaMetadata *types.MediaMetadata, absBasePath config.Path, logger *log.Entry) (types.Path, bool, error)
MoveFileWithHashCheck checks for hash collisions when moving a temporary file to its final path based on metadata The final path is based on the hash of the file. If the final path exists and the file size matches, the file does not need to be moved. In error cases where the file is not a duplicate, the caller may decide to remove the final path. Returns the final path of the file, whether it is a duplicate and an error.
func WriteTempFile ¶
func WriteTempFile( ctx context.Context, reqReader io.Reader, maxFileSizeBytes config.FileSizeBytes, absBasePath config.Path, ) (hash types.Base64Hash, size types.FileSizeBytes, path types.Path, err error)
WriteTempFile writes to a new temporary file. The file is deleted if there was an error while writing.
Types ¶
This section is empty.