upload_files.py
def upload_file(self, filepath):
        """Uploads one file.
        First it asks the API for where to place the file on S3, then it uploads
        the file to S3. It then triggers the Raptor Maps system to ingest the
        file and peform post processing
        """

        # Determine filename from filepath
        filename = os.path.basename(filepath)

        # Get AWS S3 post url so we can upload directly to S3
        endpoint = "/api/v2/token/%s/get_s3_post_link" % (self.access_token)
        url = BASE_URL + endpoint

        payload = {
            'upload_session_id': self.upload_session_id,
            'filename': filename
        }

        # POST
        r = requests.post(url, data=json.dumps(payload), headers=self.headers)

        # parse response
        data = r.json()

        if int(data['exit_status']) == 0:
            post = data['post']
        else:
            raise

        # Upload file directly to s3
        try:
            self.post_file_to_s3(filepath, post)
        except ConnectionError as e:
            print('ConnectionError:', e)
            return

        # Initialize data ingestion for this file
        endpoint = "/api/v2/token/%s/upload_file" % (self.access_token)
        url = BASE_URL + endpoint

        s3_url = post['fields']['key']

        payload = {
            'upload_session_id': self.upload_session_id,
            's3_url': s3_url,
            'data_type': 'image' # or geotiff
        }

        # POST
        r = requests.post(url, data=json.dumps(payload), headers=self.headers)

        print('------ Session %s: %s of %s: %s' % (
            self.upload_session_id, self.counter+1, self.total_file_count,
            os.path.basename(filepath)))

        self.counter += 1
Uploads one file.
        First it asks the API for where to place the file on S3, then it uploads
        the file to S3. It then triggers the Raptor Maps system to ingest the
        file and peform post processing
        
Uploads one file.
First it asks the API for where to place the file on S3, then it uploads
the file to S3. It then triggers the Raptor Maps system to ingest the
file and peform post processing
Uploads one file . First it asks the API for where to place the file on S3 then it uploads the file to S3 . It then triggers the Raptor Maps system to ingest the file and peform post processing
def upload_file(self, filepath):
        filename = os.path.basename(filepath)
        endpoint = "/api/v2/token/%s/get_s3_post_link" % (self.access_token)
        url = BASE_URL + endpoint
        payload = {
            'upload_session_id': self.upload_session_id,
            'filename': filename
        }
        r = requests.post(url, data=json.dumps(payload), headers=self.headers)
        data = r.json()
        if int(data['exit_status']) == 0:
            post = data['post']
        else:
            raise
        try:
            self.post_file_to_s3(filepath, post)
        except ConnectionError as e:
            print('ConnectionError:', e)
            return
        endpoint = "/api/v2/token/%s/upload_file" % (self.access_token)
        url = BASE_URL + endpoint
        s3_url = post['fields']['key']
        payload = {
            'upload_session_id': self.upload_session_id,
            's3_url': s3_url,
            'data_type': 'image' 
        }
        r = requests.post(url, data=json.dumps(payload), headers=self.headers)
        print('------ Session %s: %s of %s: %s' % (
            self.upload_session_id, self.counter+1, self.total_file_count,
            os.path.basename(filepath)))
        self.counter += 1
def upload_file ( self , filepath ) : filename = os . path . basename ( filepath ) endpoint = "/api/v2/token/%s/get_s3_post_link" % ( self . access_token ) url = BASE_URL + endpoint payload = { 'upload_session_id' : self . upload_session_id , 'filename' : filename } r = requests . post ( url , data = json . dumps ( payload ) , headers = self . headers ) data = r . json ( ) if int ( data [ 'exit_status' ] ) == 0 : post = data [ 'post' ] else : raise try : self . post_file_to_s3 ( filepath , post ) except ConnectionError as e : print ( 'ConnectionError:' , e ) return endpoint = "/api/v2/token/%s/upload_file" % ( self . access_token ) url = BASE_URL + endpoint s3_url = post [ 'fields' ] [ 'key' ] payload = { 'upload_session_id' : self . upload_session_id , 's3_url' : s3_url , 'data_type' : 'image' } r = requests . post ( url , data = json . dumps ( payload ) , headers = self . headers ) print ( '------ Session %s: %s of %s: %s' % ( self . upload_session_id , self . counter + 1 , self . total_file_count , os . path . basename ( filepath ) ) ) self . counter += 1
Uploads one file.
Uploads one file .
"""Uploads one file.
        First it asks the API for where to place the file on S3, then it uploads
        the file to S3. It then triggers the Raptor Maps system to ingest the
        file and peform post processing
        """ # Determine filename from filepath # Get AWS S3 post url so we can upload directly to S3 # POST # parse response # Upload file directly to s3 # Initialize data ingestion for this file # or geotiff # POST
self
filepath