这是我将文件上传到AWS S3的方式:
import cv2
import threading
class Video:
def play(self):
video = cv2.VideoCapture('small.mov')
if video.isOpened() == True:
cv2.namedWindow("The Video")
cv2.moveWindow("The Video", 500,200)
elif video.isOpened() == False:
print('No Data For Loading Video')
return 0
while video.isOpened():
_, frame = video.read()
if _ == True:
cv2.imshow("The Video",frame)
if cv2.waitKey(10) & 0xff == 27:
break
if _ == False :
break
cv2.destroyAllWindows()
video.release()
def Load():
v=Video()
v.play()
del v
t = threading.Thread(target = Load)
t.start()
然后:
const config = (req) => {
limits: { fileSize: 20000000 }, // 20 MB
storage: multerS3({
acl: 'public-read',
bucket: `${Bucket}/${orderNumber}/orderFiles`,
key(request, file, cb) {
cb(null, `${file.originalname}`);
},
metadata(request, file, cb) {
cb(null, {});
},
s3,
}),
}
uploadFiles = async req => {
try {
const uploadOrder = multer(config(req)).array('files');
return new Promise((resolve, reject) => {
uploadOrder(req, {}, error => {
const fileArray = req.files;
let fileLocation;
fileArray.forEach(file => {
fileLocation = file.location;
});
resolve(fileArray[0].bucket);
});
});
} catch (error) {
return error;
}
};
有什么方法可以检查文件是否为 zip ,然后可以解压缩zip的每个文件并将其上传到s3? 我全神贯注于互联网,无法正常工作。