updated storage account stuff to take auth id
This commit is contained in:
@@ -1,35 +1,34 @@
|
||||
import {
|
||||
createContainer,
|
||||
getContainers,
|
||||
getBlobs,
|
||||
createBlob,
|
||||
uploadFile,
|
||||
deleteBlob,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
import { deleteBlob } from "../../../actions/azurestorage";
|
||||
|
||||
import middleware from "../middleware/middleware";
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
|
||||
const ApiProxy = nextConnect();
|
||||
ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.container;
|
||||
var casefolderID = req.query.casefolderID;
|
||||
var blobName = req.query.blobname;
|
||||
var checkHash = req.query.hash;
|
||||
|
||||
var checkquerypath =
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName.toLowerCase() +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&blobname=" +
|
||||
blobName;
|
||||
|
||||
console.log(hashAPIPath(checkquerypath), checkHash);
|
||||
console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
|
||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
await deleteBlob(containerName, "files/" + blobName).then((data) => {
|
||||
await deleteBlob(
|
||||
containerName,
|
||||
casefolderID + "/files/" + blobName
|
||||
).then((data) => {
|
||||
return res.status(200).json({ data: data });
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -1,24 +1,8 @@
|
||||
import {
|
||||
createContainer,
|
||||
getContainers,
|
||||
getBlobs,
|
||||
createBlob,
|
||||
uploadFile,
|
||||
deleteBlob,
|
||||
downloadFile,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { BlobServiceClient, ContainerClient } from "@azure/storage-blob";
|
||||
import {
|
||||
DefaultAzureCredential,
|
||||
InteractiveBrowserCredential,
|
||||
EnvironmentCredential,
|
||||
ClientSecretCredential,
|
||||
} from "@azure/identity";
|
||||
import { downloadFile } from "../../../actions/azurestorage";
|
||||
|
||||
import middleware from "../middleware/middleware";
|
||||
import nextConnect from "next-connect";
|
||||
import CryptoJS from "crypto-js";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
import middleware from "../middleware/middleware";
|
||||
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
|
||||
@@ -28,21 +12,27 @@ ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.container;
|
||||
var casefolderID = req.query.casefolderID;
|
||||
var blobName = req.query.blobname;
|
||||
var checkHash = req.query.hash;
|
||||
|
||||
var checkquerypath =
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&blobname=" +
|
||||
blobName;
|
||||
blobName.trim();
|
||||
|
||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
const downloaded = await downloadFile(containerName, blobName);
|
||||
const downloaded = await downloadFile(
|
||||
containerName,
|
||||
casefolderID + "/files/" + decodeURI(blobName)
|
||||
);
|
||||
|
||||
res.setHeader(
|
||||
"content-disposition",
|
||||
"attachment; filename=" + blobName
|
||||
"attachment; filename=" + decodeURI(blobName)
|
||||
);
|
||||
return res.status(200).send(downloaded);
|
||||
} else {
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
import {
|
||||
createContainer,
|
||||
getContainers,
|
||||
getBlobs,
|
||||
createBlob,
|
||||
uploadFile,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
import { getBlobs } from "../../../actions/azurestorage";
|
||||
|
||||
import middleware from "../middleware/middleware";
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
|
||||
const ApiProxy = nextConnect();
|
||||
ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.container;
|
||||
var casefolderID = req.query.casefolderID;
|
||||
|
||||
var checkHash = req.query.hash;
|
||||
var checkquerypath = "/api/file/getbloblist?container=" + containerName;
|
||||
var checkquerypath =
|
||||
"/api/file/getbloblist?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID;
|
||||
|
||||
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
|
||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
await getBlobs(containerName).then((data) => {
|
||||
return res.status(200).json({ files: data });
|
||||
});
|
||||
} else {
|
||||
return res.status(400).json();
|
||||
}
|
||||
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
await getBlobs(containerName, casefolderID).then((data) => {
|
||||
return res.status(200).json({ files: data });
|
||||
});
|
||||
// } else {
|
||||
// return res.status(400).json();
|
||||
// }
|
||||
});
|
||||
|
||||
export const config = {
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
import {
|
||||
createContainer,
|
||||
getContainers,
|
||||
getBlobs,
|
||||
createBlob,
|
||||
uploadFile,
|
||||
getProgressBlobs,
|
||||
downloadProgressFile,
|
||||
getProgressBlobs,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
|
||||
import middleware from "../middleware/middleware";
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
|
||||
const ApiProxy = nextConnect();
|
||||
ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.container;
|
||||
var casefolderID = req.query.casefolderID;
|
||||
|
||||
var checkHash = req.query.hash;
|
||||
var checkquerypath =
|
||||
"/api/file/getprogressobjblob?container=" + containerName;
|
||||
"/api/file/getprogressobjblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID;
|
||||
|
||||
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
|
||||
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
const blobObj = await getProgressBlobs(containerName)
|
||||
.then((data) => downloadProgressFile(containerName, data.path))
|
||||
const blobObj = await getProgressBlobs(containerName, casefolderID)
|
||||
.then((data) =>
|
||||
downloadProgressFile(containerName, data.path, casefolderID)
|
||||
)
|
||||
.then((data) => {
|
||||
return res.status(200).json(data);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
createContainer,
|
||||
getContainers,
|
||||
getBlobs,
|
||||
createBlob,
|
||||
uploadFile,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
|
||||
import middleware from "../middleware/middleware";
|
||||
import nextConnect from "next-connect";
|
||||
|
||||
const ApiProxy = nextConnect();
|
||||
ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.ident;
|
||||
var checkHash = req.query.hash;
|
||||
var checkquerypath = "/api/file/setupcontainer?ident=" + containerName;
|
||||
|
||||
console.log(req.query);
|
||||
console.log(checkquerypath.length);
|
||||
console.log(hashAPIPath(checkquerypath));
|
||||
// console.log(checkquerypath, hashAPIPath(checkquerypath), checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
|
||||
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
await createContainer(containerName)
|
||||
.then((data) => {
|
||||
return res.status(200).json({ data: "success" });
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(consoleLogger(err));
|
||||
res.status(400).json(err);
|
||||
});
|
||||
// } else {
|
||||
// return res.status(400).json();
|
||||
// }
|
||||
});
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: false,
|
||||
},
|
||||
};
|
||||
|
||||
export default ApiProxy;
|
||||
@@ -14,10 +14,15 @@ ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.post(async (req, res) => {
|
||||
var checkHash = req.query.hash;
|
||||
console.log(JSON.parse(req.body.appealData));
|
||||
console.log(req.files);
|
||||
// console.log(JSON.stringify(req.body));
|
||||
// console.log(JSON.stringify(req.body.appealData));
|
||||
// console.log(req.files);
|
||||
|
||||
const appealData = JSON.parse(req.body.appealData);
|
||||
const appealData = req.body.appealData;
|
||||
const containerID = req.body.containerID;
|
||||
const casefolderID = req.body.casefolderID;
|
||||
|
||||
console.log("there are files:", Object.keys(req.files).length);
|
||||
|
||||
// var checkquerypath = "/api/file/upload";
|
||||
|
||||
@@ -25,11 +30,18 @@ ApiProxy.post(async (req, res) => {
|
||||
// console.log(hashAPIPath(checkquerypath) == "?hash=" + checkHash);
|
||||
|
||||
// if (hashAPIPath(checkquerypath) == "?hash=" + checkHash) {
|
||||
createContainer(appealData.pinswg_name.trim()).then((containerName) => {
|
||||
createBlob(appealData, containerName).then((data) => {
|
||||
uploadFile(req.files, containerName, data);
|
||||
});
|
||||
//createContainer(containerID).then((containerName) => {
|
||||
|
||||
console.log(
|
||||
"does this et folder name:",
|
||||
appealData.pinswg_name,
|
||||
casefolderID
|
||||
);
|
||||
createBlob(appealData, containerID, casefolderID).then((data) => {
|
||||
Object.keys(req.files).length > 0 &&
|
||||
uploadFile(req.files, containerID, casefolderID);
|
||||
});
|
||||
//});
|
||||
|
||||
return res.status(200).json({ data: "success" });
|
||||
// } else {
|
||||
|
||||
Reference in New Issue
Block a user