프로그래밍/Flex/AIR2008.11.13 00:40
flex의 FileReference는 전송할 때
다음과 같이 모든 파일의 content-type을 application/octet-stream 으로 전송하기 때문에


 
POST /handler.asp HTTP/1.1
Accept: text/*
Content-Type: multipart/form-data;
boundary=----------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6
User-Agent: Shockwave Flash
Host: www.mydomain.com
Content-Length: 421
Connection: Keep-Alive
Cache-Control: no-cache

------------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6
Content-Disposition: form-data; name="Filename"

sushi.jpg
------------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6
Content-Disposition: form-data; name="Filedata"; filename="sushi.jpg"
Content-Type: application/octet-stream

Test File
------------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6
Content-Disposition: form-data; name="Upload"

Submit Query
------------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6
(actual file data,,,)



content_type => :image을 쓸 수 없다.
쓴다면 'Content type is not included in the list'  이라는 에러 메시지를 볼 수 있다.
class Photo < ActiveRecord::Base
  has_attachment :storage => :file_system,
                 :max_size => 300.kilobytes,
                 :resize_to => '320x200>',
                 :thumbnails => { :thumb => '100x100>' }
                 #:content_type => :image                
  validates_as_attachment

end



저작자 표시
신고
Posted by 시난
프로그래밍/Ruby2008.11.12 23:53
http://clarkware.com/cgi/blosxom/2007/02/24

이걸보고 하면 간단

특징:
파일시스템에 올린 다음 이미지 정보들은 DB에 갖고 있음.
파일시스템 말고 DB에 바이너리로 넣을 수도..


저작자 표시
신고
Posted by 시난
프로그래밍/Ruby2008.08.19 02:07
루비의 DateTime 형식은
문자열 형식으로 찍어보면 다음과 같다.

2008-08-17T01:47:44+0900


그러나
W3C의 Date Time Format (http://www.w3.org/TR/NOTE-datetime)
형식과 유사하지만 뒷 부분이 다르다.

Formats

Different standards may need different levels of granularity in the date and time, so this profile defines six levels. Standards that reference this profile should specify one or more of these granularities. If a given standard allows more than one granularity, it should specify the meaning of the dates and times with reduced precision, for example, the result of comparing two dates with different precisions.

The formats are as follows. Exactly the components shown here must be present, with exactly this punctuation. Note that the "T" appears literally in the string, to indicate the beginning of the time element, as specified in ISO 8601.

   Year:
      YYYY (eg 1997)
   Year and month:
      YYYY-MM (eg 1997-07)
   Complete date:
      YYYY-MM-DD (eg 1997-07-16)
   Complete date plus hours and minutes:
      YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
   Complete date plus hours, minutes and seconds:
      YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
   Complete date plus hours, minutes, seconds and a decimal fraction of a
second
      YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)

where:

     YYYY = four-digit year
     MM   = two-digit month (01=January, etc.)
     DD   = two-digit day of month (01 through 31)
     hh   = two digits of hour (00 through 23) (am/pm NOT allowed)
     mm   = two digits of minute (00 through 59)
     ss   = two digits of second (00 through 59)
     s    = one or more digits representing a decimal fraction of a second
     TZD  = time zone designator (Z or +hh:mm or -hh:mm)

즉 Ruby의 '2008-08-17T01:47:44+0900' 형식이
W3CDTF로 변환되면 '2008-08-17T01:47:44+09:00' 처럼 되야 하는데

뒷 부분의 TZD(time zone designator) 형식이 다르기 때문에


com.adobe.utils.DateUtil.parseW3CDTF( '2008-08-17T01:47:44+0900' ); 을 사용할 때
문제가 발생한다.

해결법1
DateUtil.parseW3CDTF()  사용말고
DateFormatter 를 사용해 처리한다.
(time zone정보는 파싱할 수 없으므로 따로 해야함 -_-)

해결법2 (Ruby쪽)
시간 출력해주는 부분을 바꿔야 한다.
ex>
> require 'date'
> Date.today.to_s
=> "2006-08-21"

> DateTime.now.to_s
=> "2006-08-21T13:08:34-0700"

> DateTime.now..to_s[0..18]
=> "2006-08-21T13:14:15"
# Or use strftime. This example is from ActiveRecord:
user.created_at.strftime("%Y-%m-%d %H:%M:%S")

p.s. 같이 고생한(?) 찬익 쌩큐


참고:
http://whynotwiki.com/Ruby_/_Dates_and_times
http://flex2colombia.wordpress.com/2007/02/18/dateformatter-parsedatestring-replacement/
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=formatters_094_6.html
http://blog.flexexamples.com/2008/02/02/parsing-iso-dates-with-flex-and-actionscript/



신고
Posted by 시난