From dadec94340c8e254c1bb22a0370ab850a76e85ef Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 22 May 2024 09:06:11 +0200 Subject: [PATCH 1/2] docs: `Working with Files` (#817) Co-authored-by: Mark R. Florkowski --- docs/src/pages/_meta.json | 1 + docs/src/pages/working-with-files.mdx | 67 +++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 docs/src/pages/working-with-files.mdx diff --git a/docs/src/pages/_meta.json b/docs/src/pages/_meta.json index e88641d289..063bbdf2a4 100644 --- a/docs/src/pages/_meta.json +++ b/docs/src/pages/_meta.json @@ -12,6 +12,7 @@ "type": "separator" }, "backend-adapters": "Backend Adapters", + "working-with-files": "Working with Files", "auth-security": "Authentication & Security", "theming": "Theming", "regions-and-acl": "Regions and Access Controls", diff --git a/docs/src/pages/working-with-files.mdx b/docs/src/pages/working-with-files.mdx new file mode 100644 index 0000000000..00410fc99f --- /dev/null +++ b/docs/src/pages/working-with-files.mdx @@ -0,0 +1,67 @@ +import { Callout } from "nextra-theme-docs"; + +# Working with Files + +After your files have been uploaded, you will most likely want to do something +with them. This page shows how to work with your uploaded files. + +## Accessing Files + + + Do not use the raw file URL from the storage provider, e.g. `https://bucket.s3.region.amazonaws.com/`. We reserve the right to move objects between different storage providers and/or buckets, so this URL is not guaranteed to remain valid. + + +There are multiple ways to access your files. The most generic way is to +construct the URL from the `fileKey` you get back after the file has been +uploaded: + +`https://utfs.io/f/` + +This URL will always work for public files and is the default URL returned by +the API and from any SDK method. However, sometimes you may want a URL that's +scoped to your application, for example when doing image optimizations and want +to filter what URLs are allowed to be optimized on your server. For this, the +following URL can be used: + +`https://utfs.io/a//` + +By using this URL pattern, you have more granular control over what URLs are +allowed to be optimized. Below is an example of how to setup image optimization +allow filtering in Next.js: + +```js +/** @type {import('next').NextConfig} */ +export default { + images: { + remotePatterns: [ + { + protocol: "https", + hostname: "utfs.io", + pathname: "/a//*", + }, + ], + }, +}; +``` + + + If you set a `customId` when uploading the file, you can also use `https://utfs.io/a//`. + + +### Accessing Private Files + +If your files are protected with +[access controls](/regions-and-acl#access-controls), you will need to request a +short-lived presigned URL from the API to access the file. You can request one +using [`UTApi.getSignedUrl`](/api-reference/ut-api#getsignedurl), or from the +`/requestFileAccess` API endpoint (see +[OpenAPI Specification](/api-reference/openapi-spec)). + +Presigned URL follows the same patterns as above, with additional query +parameters to authenticate the request. + +## Other File Operations + +Please refer to our server SDK, [UTApi](/api-reference/ut-api) for more +information on how to work with files. You can also access the API directly +using the [OpenAPI Specification](/api-reference/openapi-spec). From d46d727c3aa5a5608d1970bfef2452bd3bb871ed Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Wed, 22 May 2024 20:20:23 +0200 Subject: [PATCH 2/2] only publish packages with package.json --- .github/workflows/release-canary.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-canary.yaml b/.github/workflows/release-canary.yaml index e44a189ad4..985193b5e8 100644 --- a/.github/workflows/release-canary.yaml +++ b/.github/workflows/release-canary.yaml @@ -29,7 +29,9 @@ jobs: run: | echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc for dir in packages/*/; do - npm publish "$dir" --access public --tag canary + if [ -d "$dir/package.json" ]; then + npm publish "$dir" --access public --tag canary + fi; done - name: Create a new comment notifying of the new canary version