def post(self): """ Accepts a file upload and sends it to the media engine to be converted """ # We accept multiple file uploads allUploadedFiles = self.request.files['file'] # List of Uploaded File IDs uploadedAssets = [] # Loop over every uploaded file for file in allUploadedFiles: # The original filename of the uploaded file originalUploadedFilename = file.filename # Create a new asset entry asset = Asset().newAsset(originalUploadedFilename, "active", {}) assetId = asset.assetId # Determine the folders & storage IDs this upload needs to be a part of folderId = self.get_argument("folder") folder = Folder(int(folderId)) for storageLocation in folder.storageLocations: storageId = storageLocation.storageLocationId self.doUpload(assetId, storageId, file) asset.folders = [int(folderId)] uploadedAssets.append(asset.data) self.set_header("Content-Type", "application/json") self.write(json.dumps( {"assets": uploadedAssets} ))
def post(self, assetId): """ Returns a specific asset """ allFields = Asset().fields asset = Asset(int(assetId)) for field in allFields: try: fieldName = field['fieldName'] fieldSubmittedValue = self.get_argument(fieldName, default = None) if field['useTaxonomy'] is True: try: fieldSubmittedValue = int(fieldSubmittedValue) except Exception, e: pass if fieldName == "title": asset.title = fieldSubmittedValue else: asset.setFieldValue(fieldName, fieldSubmittedValue) print fieldName, fieldSubmittedValue except Exception, e: print e