-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement Nostr video creation and viewing
- Loading branch information
Showing
12 changed files
with
28,711 additions
and
69 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 |
---|---|---|
|
@@ -24,4 +24,4 @@ node_modules/ | |
.env | ||
|
||
|
||
pnpm-lock.yaml | ||
pnpm-lock.yamlapps/mobile/.env |
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
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,32 @@ | ||
import axios from 'axios'; | ||
import * as FileSystem from 'expo-file-system'; | ||
|
||
export const uploadToPinata = async (fileUri: string) => { | ||
const apiKey = process.env.EXPO_PUBLIC_PINATA_API_KEY; | ||
const apiSecret = process.env.EXPO_PUBLIC_PINATA_API_SECRET; | ||
|
||
// Read the file as a binary string | ||
const fileInfo = await FileSystem.getInfoAsync(fileUri); | ||
const fileContent = await FileSystem.readAsStringAsync(fileUri, { encoding: FileSystem.EncodingType.Base64 }); | ||
|
||
const formData = new FormData(); | ||
formData.append('file', { | ||
uri: fileUri, | ||
type: 'video/mp4', | ||
name: 'video.mp4', | ||
} as any); // Use 'as any' to bypass TypeScript checks | ||
|
||
try { | ||
const res = await axios.post("https://api.pinata.cloud/pinning/pinFileToIPFS", formData, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
pinata_api_key: apiKey, | ||
pinata_secret_api_key: apiSecret, | ||
}, | ||
}); | ||
return res.data.IpfsHash; | ||
} catch (error) { | ||
console.error('Error uploading to Pinata:', error); | ||
throw error; | ||
} | ||
}; |
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
Oops, something went wrong.