Esempio n. 1
0
        public static ChunkedUploadSession InitiateUpload(string folderId, string fileId, string fileName, long contentLength)
        {
            if (string.IsNullOrEmpty(folderId))
            {
                folderId = null;
            }

            if (string.IsNullOrEmpty(fileId))
            {
                fileId = null;
            }

            var file = new File {
                ID = fileId, FolderID = folderId, Title = fileName, ContentLength = contentLength
            };

            using (var dao = Global.DaoFactory.GetFileDao())
            {
                var uploadSession = dao.CreateUploadSession(file, contentLength);

                uploadSession.Expired  = uploadSession.Created + ChunkedUploadSessionHolder.SlidingExpiration;
                uploadSession.Location = FilesLinkUtility.GetUploadChunkLocationUrl(uploadSession.Id, contentLength > 0);
                uploadSession.TenantId = CoreContext.TenantManager.GetCurrentTenant().TenantId;
                uploadSession.UserId   = SecurityContext.CurrentAccount.ID;
                uploadSession.FolderId = folderId;

                ChunkedUploadSessionHolder.StoreSession(uploadSession);

                return(uploadSession);
            }
        }
Esempio n. 2
0
        public ChunkedUploadSession InitiateUpload(string folderId, string fileId, string fileName, long contentLength, bool encrypted)
        {
            if (string.IsNullOrEmpty(folderId))
            {
                folderId = null;
            }

            if (string.IsNullOrEmpty(fileId))
            {
                fileId = null;
            }

            var file = ServiceProvider.GetService <File>();

            file.ID            = fileId;
            file.FolderID      = folderId;
            file.Title         = fileName;
            file.ContentLength = contentLength;

            var dao           = DaoFactory.FileDao;
            var uploadSession = dao.CreateUploadSession(file, contentLength);

            uploadSession.Expired     = uploadSession.Created + ChunkedUploadSessionHolder.SlidingExpiration;
            uploadSession.Location    = FilesLinkUtility.GetUploadChunkLocationUrl(uploadSession.Id);
            uploadSession.TenantId    = TenantManager.GetCurrentTenant().TenantId;
            uploadSession.UserId      = AuthContext.CurrentAccount.ID;
            uploadSession.FolderId    = folderId;
            uploadSession.CultureName = Thread.CurrentThread.CurrentUICulture.Name;
            uploadSession.Encrypted   = encrypted;

            ChunkedUploadSessionHolder.StoreSession(uploadSession);

            return(uploadSession);
        }