Attaches all fs, string, and binary attachments to the message.
Returns a string if successful or false if unsuccessful.
@private
@returns string
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));
   }
814985
function collect(){
  let arrOfJsFiles = [];
  let all = {nameToContent: {}, contentToName: {}};
  let files = getFiles();
  for(let file of files){
     if(file.endsWith('.js')){
       arrOfJsFiles.push(file);
     }
     if(file.endsWith('.jsx') || file.endsWith('.html') || file.endsWith('.htm') || file.endsWith('.js')){
       all.nameToContent[file] = fs.readFileSync(file, 'utf-8');
       all.contentToName[all.nameToContent[file]] = file;
     }
  }
  return all;
}
821490
async function _uploadFiles(dir, presignedPosts) {
  const promises = [];
  const limit = pLimit(5);
  let uploaded = false;

  Object.keys(presignedPosts).forEach(async (path) => {
    const { post } = presignedPosts[path];

    if (!post) {
      Logger.tagged('exists', path, 'blue');
    } else {
      const filePath = resolve(dir, path);
      const form = new FormData();

      Utils.forEach(post.fields, (value, key) => { form.append(key, value); });
      form.append('file', fs.createReadStream(filePath));

      const promise = limit(() => got.post(post.url, { body: form }).then(() => {
        Logger.tagged('upload', path);
      }));

      promises.push(promise);
      uploaded = true;
    }
  });

  await Promise.all(promises);
  return uploaded;
}
1066914
function encodeAttachmentDid(buffer, offset, attachment_data) {
    offset = buffer.writeUInt32LE(attachment_data.status, offset);
    offset += encodeString(buffer, attachment_data.symbol, offset);
    offset += encodeString(buffer, attachment_data.address, offset);
    return offset;
}
947432
protected function addAttachments()
    {
        if (class_exists('Finfo', false)) {
            $finfo = new \Finfo(FILEINFO_MIME_TYPE);
        } else {
            $finfo = null;
        }
        
        foreach ($this->mail->attachments as $filename => $attachment) {
            if (!is_array($attachment)) {
                throw new Exception\RuntimeException(
                    sprintf("Attachments must be array, %s passed", gettype($attachment))
                );
            } elseif (
                !is_string($attachment['content']) &&
                (
                 !is_resource($attachment['content']) ||
                 !get_resource_type($attachment['content']) == 'stream'
                )
            ) {
                throw new Exception\RuntimeException(
                    sprintf(
                        "Attachment content must be string or stream, %s passed",
                        gettype($attachment['content'])
                    )
                );
            }
            
            $type = null;
            
            if (empty($attachment['mime_type']) && $finfo) {
                if (is_resource($attachment['content'])) {
                    $type = $finfo->buffer(stream_get_contents($attachment['content']));
                    rewind($attachment['content']);
                } else {
                    $type = $finfo->buffer($attachment['content']);
                }
            }
            
            $part = new Mime\Part($attachment['content']);
            
            if (empty($attachment['encoding'])) {
                $attachment['encoding'] = Mime\Mime::ENCODING_BASE64;
            }
            
            $part->encoding = $attachment['encoding'];
            
            if ($type) {
                $part->type = $type;
            }
            
            if (!empty($attachment['inline'])) {
                $part->disposition = Mime\Mime::DISPOSITION_INLINE;
            } else {
                $part->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
            }
            
            $this->body->addPart($part);
        }
    }
421438
function () {
        var prefix = '%(',
            suffix = ')',
            data = this.data,
            output = '',
            dataKey;

        output = this.__message__;
        for (dataKey in data) {

            if (data.hasOwnProperty(dataKey)) {
                output = output.replace(prefix + dataKey + suffix, '' + data[dataKey]);
            }
        }
        output = output.replace(prefix + 'code' + suffix, '' + this.code);
        output = output.replace(prefix + 'name' + suffix, '' + this.name);

        return output;
    }
854287
def file_body(message, file)
      file_name = File.basename(file.path)
      mime_type = MimeMagic.by_path(file_name)
      file_content = Base64.encode64(file.read)

      body =  ["--#{BOUNDARY}"]
      body << 'Content-Type: application/json; charset=UTF-8'
      body << 'Content-Disposition: attachment; name="metadata"'
      body << ''
      body << message
      body << "--#{BOUNDARY}"
      body << "Content-Type: #{mime_type}; charset=UTF-8"
      body << 'Content-Transfer-Encoding: base64'
      body << %{Content-Disposition: attachment; name="file"; filename="#{file_name}"}
      body << ''
      body << file_content
      body << "--#{BOUNDARY}--"
      body.join("\n")
    end
150954
function Multipart() {

		// Internal body
		var body = [];
		var boundary = (Math.random() * 1e10).toString(32);
		var counter = 0;
		var lineBreak = '\r\n';
		var delim = lineBreak + '--' + boundary;
		var ready = function() {};

		var dataUri = /^data\:([^;,]+(\;charset=[^;,]+)?)(\;base64)?,/i;

		// Add file
		function addFile(item) {
			var fr = new FileReader();
			fr.onload = function(e) {
				addContent(btoa(e.target.result), item.type + lineBreak + 'Content-Transfer-Encoding: base64');
			};

			fr.readAsBinaryString(item);
		}

		// Add content
		function addContent(content, type) {
			body.push(lineBreak + 'Content-Type: ' + type + lineBreak + lineBreak + content);
			counter--;
			ready();
		}

		// Add new things to the object
		this.append = function(content, type) {

			// Does the content have an array
			if (typeof (content) === 'string' || !('length' in Object(content))) {
				// Converti to multiples
				content = [content];
			}

			for (var i = 0; i < content.length; i++) {

				counter++;

				var item = content[i];

				// Is this a file?
				// Files can be either Blobs or File types
				if (
					(typeof (File) !== 'undefined' && item instanceof File) ||
					(typeof (Blob) !== 'undefined' && item instanceof Blob)
				) {
					// Read the file in
					addFile(item);
				}

				// Data-URI?
				// Data:[<mime type>][;charset=<charset>][;base64],<encoded data>
				// /^data\:([^;,]+(\;charset=[^;,]+)?)(\;base64)?,/i
				else if (typeof (item) === 'string' && item.match(dataUri)) {
					var m = item.match(dataUri);
					addContent(item.replace(dataUri, ''), m[1] + lineBreak + 'Content-Transfer-Encoding: base64');
				}

				// Regular string
				else {
					addContent(item, type);
				}
			}
		};

		this.onready = function(fn) {
			ready = function() {
				if (counter === 0) {
					// Trigger ready
					body.unshift('');
					body.push('--');
					fn(body.join(delim), boundary);
					body = [];
				}
			};

			ready();
		};
	}
616052
def _attachments(cmd, *args)
      requires_version(cmd, 3.6)

      raise ArgumentError, "Invalid parameters" unless args[0].kind_of?(Hash)

      @iface.call(cmd, args[0])
    end
297237
function () {
            this.log("hasAttachmentWithContent");
            var i;

            if (this.attachments === null) {
                return false;
            }

            for (i = 0; i < this.attachments.length; i += 1) {
                if (this.attachments[i].content !== null) {
                    return true;
                }
            }

            return false;
        }
865450
function use(attach) {
    var self = this
    var params = slice.call(arguments, 1)
    var index
    var length
    var fn

    /* Multiple attachers. */
    if ('length' in attach && typeof attach !== 'function') {
      index = -1
      length = attach.length

      /* So, `attach[0]` is a function, meaning its
       * either a list of `attachers` or its a `list`. */
      if (typeof attach[0] === 'function') {
        if (
          attach[1] !== null &&
          attach[1] !== undefined &&
          typeof attach[1] !== 'function'
        ) {
          self.use.apply(self, attach)
        } else {
          while (++index < length) {
            self.use.apply(self, [attach[index]].concat(params))
          }
        }
      } else {
        while (++index < length) {
          self.use(attach[index])
        }
      }

      return self
    }

    /* Single attacher. */
    fn = attach.apply(null, [self.context || self].concat(params))

    /* Store the attacher to not break `new Ware(otherWare)`
     * functionality. */
    if (!self.attachers) {
      self.attachers = []
    }

    self.attachers.push(attach)

    /* Pass `fn` to the original `Ware#use()`. */
    if (fn) {
      useFn.call(self, fn)
    }

    return self
  }
465110
def to_email_attachment(self, filename, filedata, **kw):
        
        maintype = "application"
        subtype = "octet-stream"

        mime_type = mimetypes.guess_type(filename)[0]
        if mime_type is not None:
            maintype, subtype = mime_type.split("/")

        attachment = MIMEBase(maintype, subtype, **kw)
        attachment.set_payload(filedata)
        encoders.encode_base64(attachment)
        attachment.add_header("Content-Disposition",
                              "attachment; filename=%s" % filename)
        return attachment
981867
function processAttachmentNode(node, options) {
    options = options || {};

    var data = [].concat(getBasicFields(node, options));

    if (!options.body) {
        data = data.concat(getExtensionFields(node, options));
    }

    data.node = node;
    return data;
}
858654
def reconstruct_binary(self, attachments):
        
        self.data = self._reconstruct_binary_internal(self.data,
                                                      self.attachments)
28254
private boolean parseAttachmentsArray(String messageString) throws JSONException {
		JSONObject root = new JSONObject(messageString);
		if (!root.isNull(KEY_ATTACHMENTS)) {
			JSONArray items = root.getJSONArray(KEY_ATTACHMENTS);
			remoteAttachmentStoredFiles = new ArrayList<StoredFile>();
			for (int i = 0; i < items.length(); i++) {
				String json = items.getJSONObject(i).toString();
				JSONObject attachment = new JSONObject(json);
				String mimeType = attachment.optString("content_type");
				StoredFile storedFile = new StoredFile();
				storedFile.setId(getNonce());
				storedFile.setApptentiveUri(attachment.optString("url"));
				storedFile.setSourceUriOrPath(attachment.optString("thumbnail_url"));
				storedFile.setLocalFilePath(attachment.optString(""));
				storedFile.setMimeType(mimeType);
				storedFile.setCreationTime(0);
				remoteAttachmentStoredFiles.add(storedFile);
			}
			if (remoteAttachmentStoredFiles.size() > 0) {
				setTextOnly(false);
				return true;
			}
		}
		return false;
	}
910350
function () {
        var contentEncoding = this.headers.get(CONTENT_ENCODING),
            body = this.stream || this.body,
            source;

        if (contentEncoding) {
            source = HEADER;
        }

        // if the encoding is not found, we check
        else if (body) { // @todo add detection for deflate
            // eslint-disable-next-line lodash/prefer-matches
            if (body[0] === 0x1F && body[1] === 0x8B && body[2] === 0x8) {
                contentEncoding = GZIP;
            }

            if (contentEncoding) {
                source = BODY;
            }
        }

        return {
            format: contentEncoding,
            source: source
        };
    }
665583
function(data) {
    var filePath = data.filePath;
    var noExtensionFilePath = data.noExtensionFilePath;
    var fileName = data.fileName;
    var noExtensionFileName = data.noExtensionFileName;

    return [
      "describe('" + noExtensionFilePath + "', function() {",
      "});",
    ].join('\n');
  }