Skip to content

376: Downloads use labkey URL when file is available on Vast #377

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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/core/entity/FileDetail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ export default class FileDetail {
}

public get downloadPath(): string {
// For AICS files we don't have permission to the bucket nor do we expect to have the /allen
// drive mounted on the client machine. So we use the NGINX server to serve the file.
if (this.path.startsWith("/allen")) {
return `http://aics.corp.alleninstitute.org/labkey/fmsfiles/image${this.path}`;
// For AICS files that are available on the Vast, users can use the cloud path, but the
// download will be faster and not incur egress fees if we download via the local network.
if (this.localPath && this.localPath.startsWith("/allen")) {
return `http://aics.corp.alleninstitute.org/labkey/fmsfiles/image${this.localPath}`;
}

// Otherwise just return the path as is and hope for the best
Expand Down
29 changes: 29 additions & 0 deletions packages/core/entity/FileDetail/test/FileDetail.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect } from "chai";

import FileDetail from "..";

describe("FileDetail", () => {
describe("file path representation", () => {
it("creates downloadPath from /allen path", () => {
// Arrange
const relativePath = "path/to/MyFile.txt";

// Act
const fileDetail = new FileDetail({
file_path: `production.files.allencell.org/${relativePath}`,
annotations: [
{
name: "Local File Path",
values: [`/allen/programs/allencell/data/proj0/${relativePath}`],
},
],
});

// Assert
expect(fileDetail.downloadPath).to.equal(
// The downloadPath is HTTP, but will get redirected to HTTPS
`http://aics.corp.alleninstitute.org/labkey/fmsfiles/image/allen/programs/allencell/data/proj0/${relativePath}`
);
});
});
});
Loading