Esempio n. 1
0
 def __init__(self, request):
   FileUploadHandler.__init__(self, request)
   self._file = None
   self._starttime = 0
   self._activated = False
   # Need to directly modify FileUploadHandler.chunk_size
   FileUploadHandler.chunk_size = UPLOAD_CHUNK_SIZE.get()
Esempio n. 2
0
    def __init__(self, *args, **kwargs):
        FileUploadHandler.__init__(self, *args, **kwargs)

        ' ----- Class variables Initialization ----- '
        self._progress_id = None
        self._cache_key = "upload_status"
        cache.set(self._cache_key, {'length': 0, 'uploaded': 0})

        # print("ARGS  : {}".format(*args) )
        self._file = FTPFile(file=BytesIO(), name="tempname.jpeg")
        self._file._starttime = 0
        self._file._processed_size = 0
        self._file._chunk_index = 0
        self._activated = False

        # data = dict(*args)
        ' --------------- '

        ' ----- Chunk Size Configuration ----- '
        print("Default Chunk size = %d" % FileUploadHandler.chunk_size)
        custom_chunk_size = 102400
        FileUploadHandler.chunk_size = custom_chunk_size
        self._file._python_chunk_size = FileUploadHandler.chunk_size  # default was 65536
        self._file._ftplib_chunk_size = custom_chunk_size  # default is 64 kb i.e 64000
        print("New Chunk size = %d" % FileUploadHandler.chunk_size)
        ' --------------- '
    def __init__(self, *args, **kwargs):
        FileUploadHandler.__init__(self, *args, **kwargs)
        # print("ARGS  : {}".format(*args) )
        self._file = FTPFile(file=BytesIO(), name="tempname.jpeg")
        self._file._starttime = 0
        self._activated = False
        # data = dict(*args)
        print("SELF REQUEST : {}".format(self.request))
        data = self.request

        # self._file._ftp_remoteDir = os.path.join(data['project'], data['asset'], data['process_department'])
        self._file._ftp_remoteDir = os.path.join(data['project'],
                                                 data['asset'])

        currentDT = datetime.datetime.now()

        self._file._ftp_file_name = "%s_V(%s)_%s" % (
            data['process_department'], data['version'].replace(
                ".", "_"), data['user'].replace(".", "_"))

        # self._file._ftp_file_name = "t{}__ ".format(currentDT.strftime("%Y-%m-%d %H:%M:%S"))

        # self.request = request

        # self.url =  'ftp.some-server.com',
        # self.username = '******'
        # self.password = '******'
        # self.remotedirectory = '/path/to/files'
        print("Chunk size = %d" % FileUploadHandler.chunk_size)
Esempio n. 4
0
 def __init__(self, request):
     FileUploadHandler.__init__(self, request)
     self._file = None
     self._starttime = 0
     self._activated = False
     # Need to directly modify FileUploadHandler.chunk_size
     FileUploadHandler.chunk_size = UPLOAD_CHUNK_SIZE.get()
Esempio n. 5
0
 def __init__(self, username, uri, *args, **kwargs):
     FileUploadHandler.__init__(self, *args, **kwargs)
     self.username = username
     self.uri = uri
     # Set on each invocation of new_file()
     self.uploader = None
     self.files = {}
Esempio n. 6
0
	def __init__(self, priv_exec_path, username, real_dir, debug_mode=False):
		self.debug_mode = debug_mode
		self.priv_exec_path = priv_exec_path
		self.username = username
		self.real_dir = real_dir
		self.messages = list()
		FileUploadHandler.__init__(self)
		if self.debug_mode:
			self.debug_file = file('/tmp/upload_handler.debug', 'a')
Esempio n. 7
0
 def __init__(self, request):
   FileUploadHandler.__init__(self, request)
   self._file = None
   self._starttime = 0
   self._activated = False
   self._destination = request.GET.get('dest', None) # GET param avoids infinite looping
   self.request = request
   # Need to directly modify FileUploadHandler.chunk_size
   FileUploadHandler.chunk_size = UPLOAD_CHUNK_SIZE.get()
Esempio n. 8
0
 def __init__(self, request):
     FileUploadHandler.__init__(self, request)
     self._file = None
     self._starttime = 0
     self._activated = False
     self._destination = request.GET.get(
         'dest', None)  # GET param avoids infinite looping
     self.request = request
     # Need to directly modify FileUploadHandler.chunk_size
     FileUploadHandler.chunk_size = UPLOAD_CHUNK_SIZE.get()
Esempio n. 9
0
    def __init__(self, *args, **kwargs):
        FileUploadHandler.__init__(self, *args, **kwargs)
        self._file = None
        self._starttime = 0
        self._activated = False
        # self.request = request

        # self.url =  'ftp.some-server.com',
        # self.username = '******'
        # self.password = '******'
        # self.remotedirectory = '/path/to/files'
        LOG.debug("Chunk size = %d" % FileUploadHandler.chunk_size)
Esempio n. 10
0
  def __init__(self, request):
    FileUploadHandler.__init__(self, request)
    self._file = None
    self._starttime = 0
    self._activated = False
    self._destination = request.GET.get('dest', None) # GET param avoids infinite looping
    self.request = request
    fs = fsmanager.get_filesystem('default')
    fs.setuser(request.user.username)
    FileUploadHandler.chunk_size = fs.get_upload_chuck_size(self._destination) if self._destination else UPLOAD_CHUNK_SIZE.get()

    LOG.debug("Chunk size = %d" % FileUploadHandler.chunk_size)
Esempio n. 11
0
File: views.py Progetto: iokky/WMM
 def post(self, request):
     if request.method == 'POST':
         form = CategoryForm(request.POST, request.FILES)
         if form.is_valid():
             FileUploadHandler(request.FILES['image'])
             form.save()
             return HttpResponseRedirect('category')
Esempio n. 12
0
def user_add_news(request):
    if request.user.is_authenticated:
        if request.method == 'POST':
            form = ProfileForm(request.POST, request.FILES)
            if form.is_valid():
                title = form.cleaned_data['title']
                text = form.cleaned_data['text']
                category = form.cleaned_data['categories_news']
                category_id = CategoriesNews.objects.get(id=category)
                image = form.cleaned_data['image']
                news = UserCreateNews(title=title,
                                      description=text,
                                      categories_news=category_id,
                                      news_image=image)
                try:
                    FileUploadHandler(request.FILES['image'])
                except MultiValueDictKeyError:
                    pass
                news.save()
                return redirect('/')
            return redirect('/')
        else:
            form = ProfileForm()
            return render(request, 'blog/add_post.html', {'form': form})
    else:
        return redirect('/login')
Esempio n. 13
0
File: views.py Progetto: iokky/WMM
    def post(self, request):
        if request.method == 'POST':
            print(request.GET)
            form = ProductForm(request.POST, request.FILES)

            if form.is_valid():
                FileUploadHandler(request.FILES['image'])
                form.save()
                return HttpResponseRedirect('product')
    def __init__(self, *args, **kwargs):
        FileUploadHandler.__init__(self, *args, **kwargs)
        # print("ARGS  : {}".format(*args) )
        # self._file = None
        self._starttime = 0
        self._activated = False
        # data = dict(*args)
        print("SELF REQUEST : {}".format(self.request))
        data = self.request
        # self.ftp_remoteDir = "{}/{}".format(*args) data['project'] + data['process_department']
        self._ftp_remoteDir = os.path.join(data['project'], data['asset'],
                                           data['process_department'])
        # self.request = request

        # self.url =  'ftp.some-server.com',
        # self.username = '******'
        # self.password = '******'
        # self.remotedirectory = '/path/to/files'
        print("Chunk size = %d" % FileUploadHandler.chunk_size)
    def __init__(self, *args, **kwargs):
        FileUploadHandler.__init__(self, *args, **kwargs)

        ' ----- Class variables Initialization ----- '
        self._progress_id = None
        self._cache_key = "upload_status"
        cache.set(self._cache_key, {
            'length': 0,
            'uploaded': 0,
            'start': 0,
            'abort': 0
        })

        # print("ARGS  : {}".format(*args) )
        self._file = FTPFile(file=BytesIO(), name="tempname.jpeg")
        self._file._starttime = 0
        self._file._processed_size = 0
        self._file._ftp_chunk_index = 0
        self._chunk_index = 0
        self._file._test_ftp_upload_time = 0
        self._activated = False

        self._test_lst = []

        # data = dict(*args)
        ' --------------- '

        ' ----- Chunk Size Configuration ----- '

        # Blocksize  Time
        # 102400       40
        #  51200       30
        #  25600       28
        #  32768       30
        #  24576       31
        #  19200       34
        #  16384       61
        #  12800      144
        #
        # But if I used wireless instead, I got these times:
        #
        # Blocksize  Time
        # 204800       78
        # 102400       76
        #  51200       79
        #  25600       76
        #  32768       89
        #  24576       86
        #  19200       75
        #  16384      166
        #  12800      178
        #  64000      223   ftplib default
        #  65536            python upload handler default

        # 2.5 Megabytes = 2621440 Bytes

        # print("Default Chunk size = %d" % FileUploadHandler.chunk_size)
        # #  Upload in chunks of 10 million bytes.
        # chunkSize = 10000000

        custom_chunk_size = 2621440  # 819200 # 409600
        FileUploadHandler.chunk_size = custom_chunk_size
        self._file._python_chunk_size = FileUploadHandler.chunk_size  # default was 65536
        self._file._ftplib_chunk_size = 819200  #204800  # default is 64 kb i.e 64000
        print("New Chunk size = %d" % FileUploadHandler.chunk_size)
        ' --------------- '
Esempio n. 16
0
 def __init__(self):
     FileUploadHandler.__init__(self)
     self._buff = ""
     self._present_file = None
     self._file_count = 0
     self.BOUNDARY = self.encode_multipart_make_boundary()
Esempio n. 17
0
	def __init__(self, max_size):
		self.size_so_far = 0
		self.max_size = max_size
		self.message = ""
		FileUploadHandler.__init__(self)
Esempio n. 18
0
 def __init__(self):
     FileUploadHandler.__init__(self)
     self._buff = ""
     self._present_file = None
     self._file_count = 0
     self.BOUNDARY = self.encode_multipart_make_boundary()
Esempio n. 19
0
 def __init__(self, request):
     FileUploadHandler.__init__(self, request)
     self._file = None
     self._starttime = 0
     self._activated = False
Esempio n. 20
0
 def __init__(self):
     FileUploadHandler.__init__(self)
Esempio n. 21
0
 def __init__(self, request = None, upload_to = tempfile.gettempdir()):
     self.upload_to = upload_to
     FileUploadHandler.__init__(self, request)
Esempio n. 22
0
File: upload.py Progetto: abayer/hue
 def __init__(self, request):
   FileUploadHandler.__init__(self, request)
   self._file = None
   self._starttime = 0
   self._activated = False