mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
cont
This commit is contained in:
parent
d796503fec
commit
dbd7b7932f
2 changed files with 3 additions and 40 deletions
|
|
@ -24,7 +24,7 @@ import { Merge, PickTuple } from '../util'
|
|||
import { deepDelete, setRecentlySavedItemInRedis } from '../utils/helpers'
|
||||
import { logger } from '../utils/logger'
|
||||
import { parseSearchQuery } from '../utils/search'
|
||||
import { downloadFileFromBucket, uploadToBucket } from '../utils/uploads'
|
||||
import { downloadFromBucket, uploadToBucket } from '../utils/uploads'
|
||||
import { HighlightEvent } from './highlights'
|
||||
import { addLabelsToLibraryItem, LabelEvent } from './labels'
|
||||
|
||||
|
|
@ -1703,5 +1703,5 @@ export const downloadOriginalContent = async (
|
|||
userId: string,
|
||||
libraryItemId: string
|
||||
) => {
|
||||
return downloadFileFromBucket(originalContentFilename(userId, libraryItemId))
|
||||
return downloadFromBucket(originalContentFilename(userId, libraryItemId))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,44 +154,7 @@ export const isFileExists = async (filePath: string): Promise<boolean> => {
|
|||
return exists
|
||||
}
|
||||
|
||||
export const downloadFromUrl = async (
|
||||
contentObjUrl: string,
|
||||
timeout?: number
|
||||
) => {
|
||||
// download the content as stream and max 10MB
|
||||
const response = await axios.get<Buffer>(contentObjUrl, {
|
||||
responseType: 'stream',
|
||||
maxContentLength,
|
||||
timeout,
|
||||
})
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
export const uploadToSignedUrl = async (
|
||||
uploadSignedUrl: string,
|
||||
data: Buffer,
|
||||
contentType: string,
|
||||
timeout?: number
|
||||
) => {
|
||||
// upload the stream to the signed url
|
||||
await axios.put(uploadSignedUrl, data, {
|
||||
headers: {
|
||||
'Content-Type': contentType,
|
||||
},
|
||||
maxBodyLength: maxContentLength,
|
||||
timeout,
|
||||
})
|
||||
}
|
||||
|
||||
export const isFileExists = async (filePath: string): Promise<boolean> => {
|
||||
const [exists] = await storage.bucket(bucketName).file(filePath).exists()
|
||||
return exists
|
||||
}
|
||||
|
||||
export const downloadFileFromBucket = async (
|
||||
filePath: string
|
||||
): Promise<Buffer> => {
|
||||
export const downloadFromBucket = async (filePath: string): Promise<Buffer> => {
|
||||
const file = storage.bucket(bucketName).file(filePath)
|
||||
|
||||
const [exists] = await file.exists()
|
||||
|
|
|
|||
Loading…
Reference in a new issue