parent
f3b2a130fe
commit
d2f40d3592
|
@ -17,7 +17,7 @@ List of available parameters:
|
|||
|
||||
## Contributing
|
||||
|
||||
### Testing you Code
|
||||
### Testing Your Code
|
||||
|
||||
Before pushing your code you should verify that it will pass our online test
|
||||
suite.
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
export const curl = `# upload
|
||||
curl -X POST "https://siasky.net/skynet/skyfile" -F file=@src.jpg
|
||||
|
||||
# download
|
||||
curl "https://siasky.net/[skylink]" -o dst.jpg`;
|
||||
|
||||
export const browserjs = `import { SkynetClient } from "skynet-js";
|
||||
|
||||
// create a client
|
||||
const client = new SkynetClient();
|
||||
|
||||
// Assume we have a file from an input form.
|
||||
|
||||
async function example() {
|
||||
try {
|
||||
// upload
|
||||
const { skylink } = await client.uploadFile(file);
|
||||
console.log(\`Upload successful, skylink: \${skylink}\`);
|
||||
|
||||
// download
|
||||
await client.downloadFile(skylink);
|
||||
console.log('Download successful');
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}`;
|
||||
|
||||
export const python = `import siaskynet as skynet
|
||||
|
||||
# create a client
|
||||
|
@ -11,12 +38,6 @@ print("Upload successful, skylink: " + skylink)
|
|||
client.download_file("./dst.jpg", skylink)
|
||||
print("Download successful")`;
|
||||
|
||||
export const curl = `# upload
|
||||
curl -X POST "https://siasky.net/skynet/skyfile" -F file=@src.jpg
|
||||
|
||||
# download
|
||||
curl "https://siasky.net/[skylink]" -o dst.jpg`;
|
||||
|
||||
export const node = `const { SkynetClient } = require('@nebulous/skynet');
|
||||
|
||||
// create a client
|
||||
|
@ -39,6 +60,7 @@ import (
|
|||
skynet "github.com/NebulousLabs/go-skynet"
|
||||
)
|
||||
|
||||
// create a client
|
||||
var client = skynet.New()
|
||||
|
||||
func main() {
|
||||
|
@ -56,7 +78,3 @@ func main() {
|
|||
}
|
||||
fmt.Println("Download successful")
|
||||
}`;
|
||||
|
||||
export const ruby = ``;
|
||||
|
||||
export const php = ``;
|
||||
|
|
|
@ -25,12 +25,15 @@ export default function CodeExamples() {
|
|||
CURL
|
||||
</button>
|
||||
<button type="button" onClick={() => setActive(2)} className={classNames({ active: active === 2 })}>
|
||||
Python
|
||||
BrowserJS
|
||||
</button>
|
||||
<button type="button" onClick={() => setActive(3)} className={classNames({ active: active === 3 })}>
|
||||
Node.js
|
||||
Python
|
||||
</button>
|
||||
<button type="button" onClick={() => setActive(4)} className={classNames({ active: active === 4 })}>
|
||||
Node.js
|
||||
</button>
|
||||
<button type="button" onClick={() => setActive(5)} className={classNames({ active: active === 5 })}>
|
||||
Go
|
||||
</button>
|
||||
</div>
|
||||
|
@ -43,18 +46,24 @@ export default function CodeExamples() {
|
|||
)}
|
||||
|
||||
{active === 2 && (
|
||||
<SyntaxHighlighter wrapLines showLineNumbers={true} language="javascript" style={Colors}>
|
||||
{interpolateSnippet(snippets.browserjs)}
|
||||
</SyntaxHighlighter>
|
||||
)}
|
||||
|
||||
{active === 3 && (
|
||||
<SyntaxHighlighter wrapLines showLineNumbers={true} language="python" style={Colors}>
|
||||
{interpolateSnippet(snippets.python)}
|
||||
</SyntaxHighlighter>
|
||||
)}
|
||||
|
||||
{active === 3 && (
|
||||
{active === 4 && (
|
||||
<SyntaxHighlighter wrapLines showLineNumbers={true} language="javascript" style={Colors}>
|
||||
{interpolateSnippet(snippets.node)}
|
||||
</SyntaxHighlighter>
|
||||
)}
|
||||
|
||||
{active === 4 && (
|
||||
{active === 5 && (
|
||||
<SyntaxHighlighter wrapLines showLineNumbers={true} language="go" style={Colors}>
|
||||
{interpolateSnippet(snippets.go)}
|
||||
</SyntaxHighlighter>
|
||||
|
|
Reference in New Issue