diff --git a/src/Components/UploadPageComponents/DragAndDrop.tsx b/src/Components/UploadPageComponents/DragAndDrop.tsx
index 29e00e6e44b81163d835396e8f496c999e082e20..68dd134bec73ed9c5ce0e01be024f0cef58b77e0 100644
--- a/src/Components/UploadPageComponents/DragAndDrop.tsx
+++ b/src/Components/UploadPageComponents/DragAndDrop.tsx
@@ -16,7 +16,7 @@ GNU Affero General Public License for more details.
 You should have received a copy of the GNU Affero General Public License
 along with Plataforma Integrada MEC.  If not, see <http://www.gnu.org/licenses/>.*/
 
-import React, {useState} from 'react'
+import React, {useState, useEffect} from 'react'
 import CloudUploadIcon from '@material-ui/icons/CloudUpload';
 import {DottedBox, BlueButton} from './StyledComponents.js';
 import FileToUpload from './FileToUpload'
diff --git a/src/Components/UploadPageComponents/FileToUpload.ts b/src/Components/UploadPageComponents/FileToUpload.ts
index 9812ed81cb1fde53daed00e087e0d23b7138c554..24f3613b9b0c1415e0e882c29b301b611299ac3c 100644
--- a/src/Components/UploadPageComponents/FileToUpload.ts
+++ b/src/Components/UploadPageComponents/FileToUpload.ts
@@ -9,9 +9,18 @@ export default class FileToUpload {
     private _chunkNumber: number;
     currentChunkStartByte: number;
     currentChunkFinalByte: number;
+    uploadFinished: boolean = false;
 
     constructor(file: File, name: string, draftID : string) {
         this.request = new XMLHttpRequest();
+        this.request.onreadystatechange = function(ev: Event) {
+            if(this.readyState === XMLHttpRequest.DONE){
+                if (this.getResponseHeader('access-token') != null) {
+                    console.log(this.getResponseHeader('access-token'))
+                    sessionStorage.setItem('@portalmec/accessToken', this.getResponseHeader('access-token')!)
+                }
+            }
+        }
         this.request.overrideMimeType('application/octet-stream');
 
         this.file = file;
@@ -47,6 +56,7 @@ export default class FileToUpload {
 
             if(this.currentChunkFinalByte === this.file.size) {
                 alert('Yay, upload completed! Chao!');
+                this.uploadFinished = true;
                 return;
             } else if (remainingBytes < FileToUpload.chunkSize) {
                 // if the remaining chunk is smaller than the chunk size we defined
@@ -59,8 +69,8 @@ export default class FileToUpload {
                 this.currentChunkFinalByte = this.currentChunkStartByte + FileToUpload.chunkSize;
             }
 
-            this.uploadFile();
             this._chunkNumber = this._chunkNumber + 1
+            this.uploadFile();
         }
 
         //add attributes
@@ -74,12 +84,6 @@ export default class FileToUpload {
         formData.append('_totalSize', String(this.file.size));
         formData.append('file', chunk);
 
-        this.request.onreadystatechange = (request: XMLHttpRequest, event: Event): any => {
-            if(request.readyState === XMLHttpRequest.DONE){
-                console.log(request.getResponseHeader('access-token'))
-                sessionStorage.setItem('@portalmec/accessToken', request.getResponseHeader('access-token')!)
-            }
-        }
         this.request.send(formData);// send it now!
     }