Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds dataAtPath method to API #46

Merged
merged 1 commit into from Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Textile/API/ipfs.ts
Expand Up @@ -2,6 +2,11 @@ import { NativeModules } from 'react-native'

const { TextileNode } = NativeModules

export async function dataAtPath(path: string): Promise<string> {
const result = await TextileNode.dataAtPath(path)
return result as string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer (UIntArray) could be a better return type for "data".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is the string returned a data url?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data could be anything at that path. So, no way to properly construct a data URL. It just returns a byte slice: func (m *Mobile) DataAtPath(pth string) ([]byte, error)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. This should return Buffer or UIntArray then.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah okay, i just got lucky in that the string could just be dropped into the rn image uri

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised that worked. Maybe RN Image has some default handling of string values that made it work.

}

export async function peerId(): Promise<string> {
const result = await TextileNode.peerId()
return result as string
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@textile/react-native-sdk",
"version": "1.1.0-rc33",
"version": "1.1.0-rc34",
"description": "## Getting started",
"nativePackage": true,
"main": "dist/index.js",
Expand Down