Abyss Storage
  • Abyss Storage
  • Setup
    • Core
    • File Management
    • Webhook
    • Thumbnails
    • Bucket
    • Collection
  • About
    • Links
Powered by GitBook
On this page
  • Upload File
  • Write File
  • Download File
  • Publish a file
  • Upload from an external link
  1. Setup

File Management

PreviousCoreNextWebhook

Last updated 1 year ago

To manipulate file (, or ), you need to generate a PreSignUrl

You can securly send the PreSignUrl to your Client to let him , or a file from your storage.

When Uploading or Writing a file, it will automatically generate a new thumbnail for this file. You can disabling it by providing should_not_generate_thumbnail=true as Query params (second parameter of this uploadApplicationFile function

Upload File

// Generate a preSignUrl
const resultPreSignUrl = await getPreSignedUrlApplicationFile(
  { applicationId: "my-application-id" },
  {
    type: PreSignUrlType.UPLOAD,
    fileName: fileToUpload.name,
  },
);

const transfer = new Transfer({
  name: "My Transfer",
  type: TransferType.UPLOAD,
});

transfer.setAction(() => {
  // Set any action to trigger on Upload/Download Progression
});

// Use the PreSignUrl to upload the file
await uploadApplicationFile(
  { token: resultPreSignUrl.data.preSignUrl },
  {},
  file,
  { transfer },
);

Write File

// Generate a preSignUrl
const resultPreSignUrl = await getPreSignedUrlApplicationFile(
  { 
    applicationId: "my-application-id", 
    applicationFileId: "file-id" 
  },
  {
    type: PreSignUrlType.WRITE,
  },
);

const transfer = new Transfer({
  name: "My Transfer",
  type: TransferType.UPLOAD,
});

transfer.setAction(() => {
  // Set any action to trigger on Upload/Download Progression
});

// Use the PreSignUrl to write the new file
await writeApplicationFile(
  { token: resultPreSignUrl.data.preSignUrl },
  {},
  file,
  { transfer },
);

Download File

// Generate a preSignUrl
const resultPreSignUrl = await getPreSignedUrlApplicationFile(
  { 
    applicationId: "my-application-id", 
  },
  {
    type: PreSignUrlType.DOWNLOAD,
    userApplicationFileId: userApplicationFile.id,
  },
);

const transfer = new Transfer({
  name: "My Transfer",
  type: TransferType.DOWNLOAD,
});

transfer.setAction(() => {
  // Set any action to trigger on Upload/Download Progression
});

// Use the PreSignUrl to downloadthe new file
const result = await downloadApplicationFile(
  { token: resultPreSignUrl.data.preSignUrl },
  { transfer },
);

Publish a file

Each file get be accessed from PreSignUrl but you can also enable a public access link to let anybody download your file, such as a Image Provider for your Website

// By reseting the PublicAccess, you can also enable it
await resetPublicAccessApplicationFile({
  applicationId: "application-id",
  applicationFileId: "application-file-id",
});

// You can also disable this feature by unsetting the PublicAccess
await unsetPublicAccessApplicationFile({
  applicationId: "application-id",
  applicationFileId: "application-file-id",
});

You can download (without authentication) file by PublicAccess with downloadWithPublicAccessApplicationFile method

Upload from an external link

You can provide a link referring to a file to upload it to your storage.

await uploadFromUrlApplicationFile(
  { applicationId: "application-id" }, 
  {
    name: "filename.png",
    url: "https://some-url.com/file/download",
  },
);
upload
write
downlaod
upload
write
downlaod