Add Attachment Crumbs
972061
public function attachment() {
		if ( $this->_post->post_parent ) {
			if ( $parent_post = get_post( $this->_post->post_parent ) ) {
				$this->addHierarchyOfSingularCrumbs( $parent_post );
				$this->addCrumb(
					get_the_title( $parent_post ),
					get_permalink( $parent_post )
				);
			}
		}
		$this->addCrumb(
			$this->label('attachment', get_the_title( $this->_post ) ),
			get_permalink( $this->_post )
		);
	}
297238
def attach(ary, options = {})
      attachments = ary.is_a?(Array) ? ary : [ ary ] #force first arg to array
      post({ attachments: attachments }.merge(options))
    end
439746
function attach_all() {
      // Return text of body
      $mime = array();
      $mime[] = "This is a MIME message. If you are reading this text, you\r\n";
      $mime[] = "might want to consider changing to a mail reader that\r\n";
      $mime[] = "understands how to properly display MIME multipart messages.\r\n\r\n";
      $mime[] = sprintf("--Boundary-=%s\r\n", $this->boundary);

      // Insert body. If multipart/alternative, insert both html and plain.
      if (!empty($this->AltBody))
      {
          $mime[] = sprintf("Content-Type: %s; charset = \"%s\"; boundary = \"Boundary-=%s\";\r\n",
                            $this->ContentType, $this->CharSet, $this->subboundary);
          $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);

          $mime[] = sprintf("--Boundary-=%s\r\n", $this->subboundary);
          $mime[] = sprintf("Content-Type: text/html; charset = \"%s\";\r\n", $this->CharSet);
          $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);
          $mime[] = sprintf("%s\r\n\r\n", $this->Body);

          $mime[] = sprintf("--Boundary-=%s\r\n", $this->subboundary);
          $mime[] = sprintf("Content-Type: text/plain; charset = \"%s\";\r\n", $this->CharSet);
          $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);
          $mime[] = sprintf("%s\r\n\r\n", $this->AltBody);

          $mime[] = sprintf("\r\n--Boundary-=%s--\r\n\r\n", $this->subboundary);
      }
      else
      {
          $mime[] = sprintf("Content-Type: %s; charset = \"%s\";\r\n", $this->ContentType, $this->CharSet);
          $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);
          $mime[] = sprintf("%s\r\n", $this->Body);
      }

      // Add all attachments
      for($i = 0; $i < count($this->attachment); $i++)
      {
         // Check for string attachment
         $isString = $this->attachment[$i][5];
         if ($isString)
         {
            $string = $this->attachment[$i][0];
         }
         else
         {
            $path = $this->attachment[$i][0];
         }
         $filename = $this->attachment[$i][1];
         $name = $this->attachment[$i][2];
         $encoding = $this->attachment[$i][3];
         $type = $this->attachment[$i][4];
         $mime[] = sprintf("--Boundary-=%s\r\n", $this->boundary);
         $mime[] = sprintf("Content-Type: %s; ", $type);
         $mime[] = sprintf("name=\"%s\"\r\n", $name);
         $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n", $encoding);
	 if (preg_match("/^img\d+/",$name))
	 {
	         $mime[] = sprintf("Content-Id: %s\r\n", "<".str_pad($i,10,"0",STR_PAD_LEFT).">");
	 }
         $mime[] = sprintf("Content-Disposition: attachment; filename=\"%s\"\r\n\r\n", $name);

         // Encode as string attachment
         if($isString)
         {
            if(!$mime[] = sprintf("%s\r\n\r\n", $this->encode_string($string, $encoding)))
               return false;
         }
         else
         {
            if(!$mime[] = sprintf("%s\r\n\r\n", $this->encode_file($path, $encoding)))
               return false;
         }
      }
      $mime[] = sprintf("\r\n--Boundary-=%s--\r\n", $this->boundary);

      return(join("", $mime));
   }
1111392
def add_attachment(attachment, name = '')
      # Is it a file object or a string (url)?
      if attachment.respond_to?(:path) && attachment.respond_to?(:read)
        client.post("/cards/#{id}/attachments", {
            file: attachment,
            name: name
          })
      else
        client.post("/cards/#{id}/attachments", {
            url: attachment,
            name: name
          })
      end
    end
843992
def put_attachment(self, attachmentid, attachment_update):
        ''''''
        assert type(attachment_update) is DotDict
        if (not 'ids' in attachment_update):
            attachment_update.ids = [attachmentid]

        return self._put('bug/attachment/{attachmentid}'.format(attachmentid=attachmentid),
                json.dumps(attachment_update))
451523
private static void addAttachments(Map<String, ? extends Attachment> attachments,
                                   Map<String, Object> outMap,
                                   boolean shouldInline,
                                   int minRevPos) {
        // Use a LinkedHashMap which has "predictable iteration order" - this means that the
        // serializer will output the _attachments entries in the same order as the multipart bodies
        // Note that we have already sorted entries by their key (see below where a TreeMap is used)
        // se we only need *this* map to have an iteration order which is in the insertion order
        LinkedHashMap<String, Object> attsMap = new LinkedHashMap<String, Object>();
        outMap.put("_attachments", attsMap);

        // first sort by attachment name - this means that the
        // entries in the _attachments dictionary are in the same
        // order as the multiparts
        attachments = new TreeMap<String, Attachment>(attachments);
        for (Map.Entry<String, ? extends Attachment> att : attachments.entrySet()) {
            // we need to cast down to SavedAttachment, which we know is what the AttachmentManager gives us
            SavedAttachment savedAtt = (SavedAttachment) att.getValue();
            HashMap<String, Object> theAtt = new HashMap<String, Object>();
            try {
                // add the attachment if it's newer than the minimum revpos
                if (savedAtt.revpos > minRevPos) {
                    if (!shouldInline) {
                        theAtt.put("follows", true);
                    } else {
                        theAtt.put("follows", false);
                        // base64 encode this attachment
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        OutputStream bos = Base64OutputStreamFactory.get(baos);
                        InputStream fis = savedAtt.getInputStream();
                        try {
                            int bufSiz = 1024;
                            byte[] buf = new byte[bufSiz];
                            int n = 0;
                            do {
                                n = fis.read(buf);
                                if (n > 0) {
                                    bos.write(buf, 0, n);
                                }
                            } while (n > 0);
                            // out of paranoia, close and flush - docs don't say what you have to
                            // do to

                            // ensure all base64 is written, but close seems to do the right
                            // thing with
                            // the apache codec implementation
                            bos.flush();
                            bos.close();
                            theAtt.put("data", new String(baos.toByteArray(), "UTF-8")); //base64 of data
                        } finally {
                            IOUtils.closeQuietly(fis);
                        }
                    }
                    theAtt.put("length", savedAtt.length);
                    theAtt.put("encoded_length", savedAtt.encodedLength);
                    theAtt.put("content_type", savedAtt.type);
                    theAtt.put("revpos", savedAtt.revpos);
                    if (savedAtt.encoding != Attachment.Encoding.Plain) {
                        theAtt.put("encoding", savedAtt.encoding.toString().toLowerCase(Locale.ENGLISH));
                    }
                } else {
                    // if the revpos of the attachment is higher than the minimum, it's a stub
                    theAtt.put("stub", true);
                }
            } catch (IOException ioe) {
                // if we can't read the file containing the attachment then skip it
                // (this should only occur if someone tampered with the attachments directory
                // or something went seriously wrong)
                logger.log(Level.WARNING,String.format("Error reading attachment %s",att),ioe);
                continue;
            }
            // now we are done, add the attachment to the map
            attsMap.put(att.getKey(), theAtt);
        }
    }
120959
function insertMultipart (doc, attachments, qs, callback) {
      if (typeof qs === 'string') {
        qs = { docName: qs }
      }
      qs = qs || {}

      const docName = qs.docName
      delete qs.docName

      doc = Object.assign({ _attachments: {} }, doc)

      const multipart = []

      attachments.forEach(function (att) {
        doc._attachments[att.name] = {
          follows: true,
          length: Buffer.isBuffer(att.data)
            ? att.data.length : Buffer.byteLength(att.data),
          /* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
          'content_type': att.content_type
        }
        multipart.push({ body: att.data })
      })

      multipart.unshift({
        'content-type': 'application/json',
        body: JSON.stringify(doc)
      })

      return relax({
        db: dbName,
        method: 'PUT',
        contentType: 'multipart/related',
        doc: docName,
        qs: qs,
        multipart: multipart
      }, callback)
    }
1346105
protected function autoAddItems()
    {
        if ($this->config->get('crumbs.display_both_pages')) {
            $this->addHomePage();

            if ($this->request->is($this->config->get('crumbs.admin_pattern'))) {
                $this->addAdminPage();
            }
        } else {
            if ($this->config->get('crumbs.display_home_page') && !$this->request->is($this->config->get('crumbs.admin_pattern'))) {
                $this->addHomePage();
            }
            if ($this->config->get('crumbs.display_admin_page') && $this->request->is($this->config->get('crumbs.admin_pattern'))) {
                $this->addAdminPage();
            }
        }
    }
468735
private void addAttachment(Multipart multipart, Attachment attachment) throws AttachmentResourceHandlerException {
		MimeBodyPart part = new MimeBodyPart();
		try {
			part.setFileName(attachment.getResource().getName());
			part.setDisposition(attachment.getDisposition());
			part.setDescription(attachment.getDescription());
			part.setContentID(attachment.getContentId());
			attachmentHandler.setData(part, attachment.getResource(), attachment);
			multipart.addBodyPart(part);
		} catch (MessagingException e) {
			throw new AttachmentResourceHandlerException("Failed to attach " + attachment.getResource().getName(), attachment, e);
		}
	}
1347744
function getCrumbTrail( crumbs )
{
	var xhtml = DISPLAY_PREPREND;

	for( var i = 0; i < crumbs.length; i++ )
	{
		xhtml += '<a href="' + crumbs[i][1] + '" >';
		xhtml += unescape( crumbs[i][0] ) + '</a>';
		if( i != (crumbs.length-1) )
		{
			xhtml += DISPLAY_SEPARATOR;
		}
	}

	xhtml += DISPLAY_POSTPREND;

	return xhtml;
}
366175
def attachComplete():
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x3)  # 00000011
    packet = a / b
    return packet
207346
def index
      add_breadcrumb t('integral.breadcrumbs.tags'), nil
      @tags = Integral::Post.all_tag_counts(order: 'count desc').paginate(page: params[:page])
    end
599775
protected function setBreadcrumbEditDownload()
    {
        $breadcrumbs = array();

        $breadcrumbs[] = array(
            'text' => $this->text('Dashboard'),
            'url' => $this->url('admin')
        );

        $breadcrumbs[] = array(
            'text' => $this->text('Modules'),
            'url' => $this->url('admin/module/list')
        );

        $this->setBreadcrumbs($breadcrumbs);
    }
376702
public function download_attachments()
    {
        $rcmail = rcmail::get_instance();

        // require CSRF protected request
        $rcmail->request_security_check(rcube_utils::INPUT_GET);

        $imap      = $rcmail->get_storage();
        $temp_dir  = $rcmail->config->get('temp_dir');
        $tmpfname  = tempnam($temp_dir, 'zipdownload');
        $tempfiles = array($tmpfname);
        $message   = new rcube_message(rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET));

        // open zip file
        $zip = new ZipArchive();
        $zip->open($tmpfname, ZIPARCHIVE::OVERWRITE);

        foreach ($message->attachments as $part) {
            $pid      = $part->mime_id;
            $part     = $message->mime_parts[$pid];
            $disp_name = $this->_create_displayname($part);

            $tmpfn       = tempnam($temp_dir, 'zipattach');
            $tmpfp       = fopen($tmpfn, 'w');
            $tempfiles[] = $tmpfn;

            $message->get_part_body($part->mime_id, false, 0, $tmpfp);
            $zip->addFile($tmpfn, $disp_name);
            fclose($tmpfp);
        }

        $zip->close();

        $filename = ($this->_filename_from_subject($message->subject) ?: 'attachments') . '.zip';

        $this->_deliver_zipfile($tmpfname, $filename);

        // delete temporary files from disk
        foreach ($tempfiles as $tmpfn) {
            unlink($tmpfn);
        }

        exit;
    }
602685
@InterfaceAudience.Private
    protected static Map<String, Object> installAttachmentBodies(Map<String, Object> attachments,
                                                                 Database database)
            throws CouchbaseLiteException {
        Map<String, Object> updatedAttachments = new HashMap<String, Object>();
        for (String name : attachments.keySet()) {
            Object value = attachments.get(name);
            if (value instanceof Attachment) {
                Attachment attachment = (Attachment) value;
                Map<String, Object> metadataMutable = new HashMap<String, Object>();
                metadataMutable.putAll(attachment.getMetadata());
                InputStream body = attachment.getBodyIfNew();
                if (body != null) {
                    // Copy attachment body into the database's blob store:
                    BlobStoreWriter writer;
                    try {
                        writer = blobStoreWriterForBody(body, database);
                    } catch (Exception e) {
                        throw new CouchbaseLiteException(e.getMessage(), Status.ATTACHMENT_ERROR);
                    }
                    metadataMutable.put("length", writer.getLength());
                    metadataMutable.put("digest", writer.mD5DigestString());
                    metadataMutable.put("follows", true);
                    database.rememberAttachmentWriter(writer);
                }
                updatedAttachments.put(name, metadataMutable);
            } else if (value instanceof AttachmentInternal) {
                throw new IllegalArgumentException("AttachmentInternal objects not expected here.  Could indicate a bug");
            } else if (value != null) {
                updatedAttachments.put(name, value);
            }
        }
        return updatedAttachments;
    }
598571
def entry_breadcrumbs(entry):
    
    date = entry.publication_date
    if is_aware(date):
        date = localtime(date)
    return [year_crumb(date), month_crumb(date),
            day_crumb(date), Crumb(entry.title)]
950787
function packFiles (tempPath, files, callback) {
  var self = this

  async.eachSeries(files, function (crtFile, done) {
    var filePath = path.resolve(crtFile.src[0])
    debug('adding %s', filePath)
    async.waterfall([
      fs.stat.bind(fs, filePath),
      function (stats, wtfDone) {
        if (stats.isDirectory()) {
          addParentDirs(self.data, crtFile.dest, self.dirs, done)
        } else {
          async.waterfall([
            fs.readFile.bind(fs, filePath),
            function writeFileToTarball (data, wtf2Done) {
              self.data.entry({
                name: '.' + crtFile.dest,
                size: stats.size
              }, data, function (err) {
                wtf2Done(err, data)
              })
            },

            function processFile (fileData, wtf2Done) {
              self.pkgSize += stats.size

              self.filesMd5.push({
                path: crtFile.dest,
                md5: crypto.createHash('md5').update(fileData).digest('hex')
              })

              wtf2Done()
            }
          ], wtfDone)
        }
      }
    ], done)
  }, function (err) {
    if (err) {
      debug('there was a problem adding files to the .deb package: ', err)
      callback(err)
    } else {
      debug('successfully added files to .deb package')

      var file = fs.createWriteStream(path.join(tempPath, 'data.tar.gz'))
      file.on('finish', callback)

      var compress = zlib.createGzip()
      compress.pipe(file)

      self.data.pipe(compress)
      self.data.finalize()
    }
  })
}