https://developer.zendesk.com/rest_api/docs/core/macros#show-macro-attachment
421689
def macros_attachment_show(self, id, **kwargs):
        ""
        api_path = "/api/v2/macros/attachments/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, **kwargs)
247379
def document_endpoint(endpoint):
    """"""
    descr = clean_description(py_doc_trim(endpoint.__doc__))
    docs = {
        'name': endpoint._route_name,
        'http_method': endpoint._http_method,
        'uri': endpoint._uri,
        'description': descr,
        'arguments': extract_endpoint_arguments(endpoint),
        'returns': format_endpoint_returns_doc(endpoint),
    }
    if hasattr(endpoint, "_success"):
        docs["success"] = endpoint._success
    if hasattr(endpoint, "_requires_permission"):
        docs["requires_permission"] = endpoint._requires_permission
    return docs
974272
def _get_attachments(self, id):
        """"""
        uri = '/'.join([self.base_url, self.name, id, 'Attachments']) + '/'
        return uri, {}, 'get', None, None, False
1280495
def attachment_title(attachment)
      attachment.title.is_a?(Hash) ? translated_attribute(attachment.title) : attachment.title
    end
945550
def help_center_articles_attachment_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/help_center/articles/attachments.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
394462
function AddAttachment($path, $name = "", $encoding = "base64", $type = "application/octet-stream") {
      if(!@is_file($path))
      {
         $this->error_handler(sprintf("Could not find %s file on filesystem", $path));
         return false;
      }

      $filename = basename($path);
      if($name == "")
         $name = $filename;

      // Append to $attachment array
      $cur = count($this->attachment);
      $this->attachment[$cur][0] = $path;
      $this->attachment[$cur][1] = $filename;
      $this->attachment[$cur][2] = $name;
      $this->attachment[$cur][3] = $encoding;
      $this->attachment[$cur][4] = $type;
      $this->attachment[$cur][5] = false; // isStringAttachment

      return true;
   }
713039
def attachment_thumbnail
      if file_extension == "pdf" && attachment[:thumbnail_url]
        image_tag(attachment[:thumbnail_url])
      elsif file_extension == "html"
        image_tag('pub-cover-html.png')
      elsif %w{doc docx odt}.include?(file_extension)
        image_tag('pub-cover-doc.png')
      elsif %w{xls xlsx ods csv}.include?(file_extension)
        image_tag('pub-cover-spreadsheet.png')
      else
        image_tag('pub-cover.png')
      end
    end
1008831
def organization_field_show(self, id, **kwargs):
        ""
        api_path = "/api/v2/organization_fields/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, **kwargs)
228447
function(params, callback) {
                getImageData = {};

                if (params) {
                    if (parseInt(params.imageId) > 0) {
                        getImageData.imageId = params.imageId;
                    }

                    if (typeof params.hashCode == 'string') {
                        getImageData.hashCode = params.hashCode;
                    }

                    if (parseInt(params.width) > 0) {
                        getImageData.width = params.width;
                    }

                    if (parseInt(params.height) > 0) {
                        getImageData.height = params.height;
                    }

                    if (parseInt(params.actual) > 0) {
                        getImageData.actual = params.actual;
                    }

                    if (parseInt(params.downloadable) > 0) {
                        getImageData.downloadable = params.downloadable;
                    }
                }

                httpRequest({
                    url: SERVICE_ADDRESSES.FILESERVER_ADDRESS + SERVICES_PATH.GET_IMAGE,
                    method: 'GET',
                    data: getImageData
                }, function(result) {
                    if (!result.hasError) {
                        var queryString = '?';
                        for (var i in params) {
                            queryString += i + '=' + params[i] + '&';
                        }
                        queryString = queryString.slice(0, -1);
                        var image = SERVICE_ADDRESSES.FILESERVER_ADDRESS + SERVICES_PATH.GET_IMAGE + queryString;
                        callback({
                            hasError: result.hasError,
                            result: image
                        });
                    }
                    else {
                        callback({
                            hasError: true
                        });
                    }
                });
            }
206639
def macro_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/macros.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
147845
def get_attachment_data(self, attachment):
        
        f = attachment.getAttachmentFile()
        attachment_type = attachment.getAttachmentType()
        attachment_keys = attachment.getAttachmentKeys()
        filename = f.filename
        filesize = self.get_filesize(f)
        mimetype = f.getContentType()
        report_option = attachment.getReportOption()

        return {
            "obj": attachment,
            "attachment_type": attachment_type,
            "attachment_keys": attachment_keys,
            "file": f,
            "uid": api.get_uid(attachment),
            "filesize": filesize,
            "filename": filename,
            "mimetype": mimetype,
            "report_option": report_option,
        }
98345
def sub_macros(string,base_url):
    '''
    
    '''
    macros = { '|url|': base_url,
               '|media|': os.path.join(base_url,'media'),
               '|page|': os.path.join(base_url,'page')
             }
    for key, val in macros.items():
        string = string.replace(key,val)
    return string
827356
function loadAttachments (doc, directory, callback) {
  doc._attachments = doc._attachments || {};
  glob('**/*', { cwd: directory }, function (err, files) {
    async.each(files, function (file, done) {
      if (file.indexOf('_') === 0) return done();
      fs.stat(path.join(directory, file), function (err, stat) {
        if (err) return done(err);
        if (stat.isFile()) {
          fs.readFile(path.join(directory, file), function (err, data) {
            if (err) return done(err);
            var ext = file.split('.').pop()
            doc._attachments[file] = {}
            doc._attachments[file]['content_type'] = lookup(ext);
            doc._attachments[file]['data'] = data.toString('base64');
            done();
          });
        } else {
          done();
        }
      });
    }, function (err) {
      callback.call(null, err, doc);
    });
  });
}
758768
function prepareAttachmentForJS($response, $attachment, $meta) {
		if(!$response || empty($response) || !isset($response['sizes'])) {
			return $response;
		}

		if($this->renderPDF && isset($meta['s3'])) {
			if($attachment->post_mime_type == 'application/pdf') {
				$response['type'] = 'image';
				$response['mime'] = 'image/pdf';
				if(isset($meta['width'])) {
					$response['width'] = round($meta['width']);
				}

				if(isset($meta['height'])) {
					$response['height'] = round($meta['height']);
				}

				if(isset($response['width']) && isset($response['height'])) {
					$response['orientation'] = ($response['width'] > $response['height']) ? 'landscape' : 'portrait';
				}
			}
		}

		$generateUrls = !($this->skipGifs && ($attachment->post_mime_type == 'image/gif'));
		if ($generateUrls) {
            foreach($response['sizes'] as $key => $sizeInfo) {
                $res = $this->buildImgixImage($response['id'], $key);
                if(is_array($res)) {
                    $response['sizes'][$key]['url'] = $res[0];
                }
            }
        }

		return $response;
	}
109179
function Attachment(options) {
    this.fileName = options.fileName;
    this.contents = options.contents;
    this.filePath = options.filePath;
    this.streamSource = options.streamSource;
    this.contentType = options.contentType;
    this.cid = options.cid;
}
64832
def find_attachment(resource_id, attachment_id)
      http.get("#{attachment_endpoint(resource_id)}/#{attachment_id}") do |response|
        Rexpense::Entities::Attachment.new response.parsed_body
      end
    end
483891
def attachment_field(method, options = {})
      render(partial:"admin/shared/forms/attachment_field", locals: {
        f: self,
        method: method,
        options: options,
      })
    end