Skip to content

Commit

Permalink
populate remaining pages and fix terminal highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
amozoss committed Aug 22, 2023
1 parent e1caea0 commit 466d603
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 27 deletions.
101 changes: 100 additions & 1 deletion app/dcs/Objects/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,103 @@ title: Objects
weight: 6
---

🚧
## Upload file

Copy a file to your bucket.

{% tabs %}

{% tab label="rclone" %}

```shell {% title="rclone" %}
# link[8:11] https://rclone.org/commands/rclone_copy/
# terminal
rclone copy ~/Downloads/storj-tree.png storj:my-bucket/
```

{% /tab %}

{% tab label="aws cli" %}

```shell {% title="aws cli" %}
# focus
# terminal
aws s3 --endpoint-url=https://gateway.storjshare.io cp ~/Downloads/storj-tree.png s3://my-bucket/

upload: Downloads/storj-tree.png to s3://my-bucket/storj-tree.png
```

{% /tab %}

{% tab label="uplink" %}

```shell {% title="uplink" %}
# terminal
uplink cp ~/Downloads/storj-tree.png sj://my-bucket
```

{% /tab %}

{% tab label="Storj Console" %}

1. Navigate to **Buckets** on the left side menu

1. Select your bucket from the list

1. Select **Upload**

![](https://link.storjshare.io/raw/jua7rls6hkx5556qfcmhrqed2tfa/docs/images/storj-console-upload.png)

{% /tab %}

{% /tabs %}

## Download file

Copy a file from your bucket.

{% tabs %}

{% tab label="rclone" %}

```shell {% title="rclone" %}
# terminal
# link[8:11] https://rclone.org/commands/rclone_copy/
rclone copy storj:my-bucket/ ~/Downloads/storj-tree-2.png
```

{% /tab %}

{% tab label="aws cli" %}

```shell {% title="aws cli" %}
# terminal
aws s3 --endpoint-url=https://gateway.storjshare.io cp s3://my-bucket/ ~/Downloads/storj-tree-2.png
```

{% /tab %}

{% tab label="uplink" %}

```shell {% title="uplink" %}
# terminal
uplink cp sj://my-bucket ~/Downloads/storj-tree.png
```

{% /tab %}

{% tab label="Storj Console" %}

1. Navigate to **Buckets** on the left side menu

1. Select your bucket from the list

1. Click the 3-dots to show the additonal options menu

1. Select **Download**

![](https://link.storjshare.io/raw/jua7rls6hkx5556qfcmhrqed2tfa/docs/images/storj-console-download.png)

{% /tab %}

{% /tabs %}
1 change: 1 addition & 0 deletions app/dcs/api/s3/s3-compatility/page.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: S3 Compatibility
docId: eZ4caegh9queuQuaazoo
weight: 1
redirects:
- /dcs/api-reference/s3-compatible-gateway/supported-s3-commands
Expand Down
14 changes: 13 additions & 1 deletion app/dcs/buckets/data-location/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@ weight: 4
docId: eem7iong0aSh7ahbich5
---

🚧
Storj is globally distributed by default and has [more consistent performance](https://www.storj.io/blog/why-todays-cloud-storage-has-inconsistent-performance-and-how-to-fix-it) than a single region on AWS S3 across many geographic locations.

When a download is requested on Storj, the segments located closest to the destination are typically used to satisfy the request as illustrated in the graphic below.

![](https://link.storjshare.io/raw/jua7rls6hkx5556qfcmhrqed2tfa/docs/images/storj_download_distributed_cloud.png)

## Setting the region

Most [S3 compatible tools](docId:REPde_t8MJMDaE2BU8RfQ) require setting an region in their configuration. For these tools, the region can be set to `global`.

```js
const s3Client = new S3.S3Client({ region: 'global' })
```
30 changes: 29 additions & 1 deletion app/dcs/buckets/object-lifecycles/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,32 @@ title: Object Lifecycles
weight: 10
---

🚧
It's possible to specify TTL for the object by sending the `X-Amz-Meta-Object-Expires` header (see [](docId:eZ4caegh9queuQuaazoo#object-level-ttl)) with one of the following:

- a signed, positive sequence of decimal numbers, each with an optional fraction
and a unit suffix, such as `+300ms`, `+1.5h`, or `+2h45m`
- valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`
- `+2h` means the object expires 2 hours from now
- full RFC3339-formatted date

{% code-group %}

```shell {% title="rclone" %}
# terminal
rclone copy storj-tree.png storj:my-bucket --header-upload "x-amz-meta-object-expires:+5m"
```

```shell {% title="aws cli" %}
# terminal
aws s3 --endpoint-url https://gateway.storjshare.io cp storj-tree.png s3://my-bucket --metadata "Object-Expires=+5m"
# terminal
aws s3 --endpoint-url https://gateway.storjshare.io cp storj-tree.png s3://my-bucket --metadata Object-Expires=2022-05-19T00:10:55Z
```

```shell {% title="uplink" %}
# uses `--expires` instead
# terminal
uplink cp --expires "+5m" storj-tree.png sj://my-bucket
```

{% /code-group %}
1 change: 1 addition & 0 deletions app/dcs/code/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "title": "Code Examples"}
5 changes: 0 additions & 5 deletions app/dcs/code/aws/page.md

This file was deleted.

5 changes: 0 additions & 5 deletions app/dcs/code/page.md

This file was deleted.

20 changes: 10 additions & 10 deletions src/components/Code.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ const usePreferredLanguageStore = create((set) => ({
...state.preferredLanguages.filter(
(preferredLanguage) => preferredLanguage !== language
),
language,
language.toLowerCase(),
],
})),
}))

export function useTabGroupProps(availableLanguages) {
availableLanguages = availableLanguages.map((lang) => lang.toLowerCase())
let { preferredLanguages, addPreferredLanguage } = usePreferredLanguageStore()
let [selectedIndex, setSelectedIndex] = useState(0)
let activeLanguage = [...availableLanguages].sort(
Expand Down Expand Up @@ -178,23 +179,22 @@ export function useTabGroupProps(availableLanguages) {
export function CodeGroup({ children, title, languages, ...props }) {
let tabGroupProps = useTabGroupProps(languages)
let hasTabs = children.length > 1
let Container = hasTabs ? Tab.Group : 'div'
let containerProps = hasTabs ? tabGroupProps : {}
let headerProps = hasTabs
? { selectedIndex: tabGroupProps.selectedIndex }
: {}

if (!hasTabs) {
return <CodePanel {...props}>{children}</CodePanel>
}

return (
<Container
{...containerProps}
<Tab.Group
{...tabGroupProps}
className="not-prose my-8 overflow-hidden rounded-xl bg-slate-900 shadow-lg dark:bg-slate-800/60 dark:shadow-none dark:ring-1 dark:ring-slate-300/10"
>
<CodeGroupHeader title={title} languages={languages} {...headerProps} />
<CodeGroupHeader
title={title}
languages={languages}
selectedIndex={tabGroupProps.selectedIndex}
/>
<CodeGroupPanels {...props}>{children}</CodeGroupPanels>
</Container>
</Tab.Group>
)
}
10 changes: 6 additions & 4 deletions src/components/Fence.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,27 @@ export default async function Fence({ language, children: code, copy = true }) {
let extensions = [link, focus, unfocusInline]
const extensionNames = extensions.map((e) => e.name)
let { code: newCode, annotations } = await extractAnnotations(
code || '',
code.trim() || '',
language || 'text',
extensionNames
)

let parsedCode = ''
const lines = newCode.split('\n')
annotations.forEach((annotation) => {
// Exclude all other code when copying
if (annotation.name === 'terminal') {
let parsedCode = ''
annotation.ranges.forEach((range) => {
const fromLineNumber = range.fromLineNumber
const toLineNumber = range.toLineNumber
const lines = newCode.split('\n')
const rangeLines = lines.slice(fromLineNumber - 1, toLineNumber)
parsedCode += rangeLines.join('\n') + '\n'
})
newCode = parsedCode
}
})
if (parsedCode !== '') {
newCode = parsedCode
}

let codeComp = (
<Code className="group" lang={language} extensions={extensions}>
Expand Down

0 comments on commit 466d603

Please sign in to comment.